Head 0 loop no head tail len 0 v 1 next v 2 next loop

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: -> loop n.next (1+len)! 47 end! ! Tail Calls and Itera@ve length Workspace ( 0)! Stack length q Heap fun (q:'a queue) ->! let rec loop (no:…) (len:int)=! …! in! loop q.head 0! q loop head! tail! 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)! 48 end! ! Tail Calls and Itera@ve length Workspace ( 0)! Stack length q Heap fun (q:'a queue) ->! let rec loop (no:…) (len:int)=! …! in! loop q.head 0! q loop head! tail! 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)! 49 end! ! Tail Calls and Itera@ve length Workspace begin match no with! | None -> len! | Some n -> loop n.next (1+len)! end! Stack length q Heap fun (q:'a queue) ->! let rec loop (no:…) (len:int)=! …! in! loo...
View Full Document

Ask a homework question - tutors are online