Let rec loop no a qnode option unit begin match no

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: 0! loop no head! tail! len 2! v! 1! next! v! next! 2! None! loop CIS120 / Spring 2012 fun (no:'a qnode option) (len:int) -> begin match no with! | None -> len! | Some n -> loop n.next (1+len)! 69 end! ! Tail Calls and Itera@ve length Workspace begin match 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! loop q.head 0! loop no head! tail! len 2! v! 1! next! v! next! 2! None! loop CIS120 / Spring 2012 fun (no:'a qnode option) (len:int) -> begin match no with! | None -> len! | Some n -> loop n.next (1+len)! 70 end! ! Tail Calls and Itera@ve length Workspace len! Stack length q Heap fun (q:'a queue) ->! let rec loop (no:…) (len:int)=! …! in! loop q.head 0! loop no head! tail! len 2! v! 1! next! v! next! 2! None! loop CIS120 / Spring 2012 fun (no:'a qnode option) (len:int) -> begin match no with! | None -> len! | Some n -&gt...
View Full Document

This document was uploaded on 11/24/2013.

Ask a homework question - tutors are online