1 0 q tail loop v 1 next no n 1 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: ! end! q tail! loop v! ( )! 1! next! no n 1+( )! no v! next! 2! None! fun (no: …) ->! begin match no with! | None -> 0! | Some n -> 1 + (loop n.next)! end! n 1+( )! no CIS120 / Spring 2012 31 Stack length Evalua@ng length q Workspace ( Heap fun (q:'a queue) ->! let rec loop (no:…) : int =! …! in! loop q.head ! )! head! begin match no with! | None -> 0! | Some n -> 1 + (loop n.next)! end! q tail! loop v! ( )! 1! next! no n 1+( )! no v! next! 2! None! fun (no: …) ->! begin match no with! | None -> 0! | Some n -> 1 + (loop n.next)! end! n 1+( )! no CIS120 / Spring 2012 32 Stack length Evalua@ng length q Workspace ( Heap fun (q:'a queue) ->! let rec loop (no:…) : int =! …! in! loop q.head ! )! head! 0! q tail! loop v! ( )! 1! next! no n 1+( )! no v! next! 2! None! fun (no: …) ->! begin match no with! | None -> 0! | Some n -> 1 + (loop n.next)! end! n 1+(...
View Full Document

This document was uploaded on 11/24/2013.

Ask a homework question - tutors are online