Lec15

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: 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 0! 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)! 52 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 0! 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)! 53 end! ! Tail Calls and Itera@ve length Workspace (loop n.next (1+len...
View Full Document

This document was uploaded on 11/24/2013.

Ask a homework question - tutors are online