Next 1len 62 end tail calls and iterave length

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Spring 2012 fun (no:'a qnode option) (len:int) -> begin match no with! | None -> len! | Some n -> loop n.next (1+len)! 56 end! ! Tail Calls and Itera@ve length Workspace ( (1+0))! Stack length q Heap fun (q:'a queue) ->! let rec loop (no:…) (len:int)=! …! in! loop q.head 0! loop no head! tail! len 0! n v! 1! next! v! 2! next! loop CIS120 / Spring 2012 fun (no:'a qnode option) (len:int) -> begin match no with! | None -> len! | Some n -> loop n.next (1+len)! 57 end! ! Tail Calls and Itera@ve length Workspace ( 1)! Stack length q Heap fun (q:'a queue) ->! let rec loop (no:…) (len:int)=! …! in! loop q.head 0! loop no head! tail! len 0! n v! 1! next! v! 2! next! loop CIS120 / Spring 2012 fun (no:'a qnode option) (len:int) -> begin match no with! | None -> len! | Some n -> loop n.next (1+len)! 58 end! ! Tail Calls and Itera@ve length Workspace begin match...
View Full Document

Ask a homework question - tutors are online