set!. We glossed over it with the 'object' example.
mcons, mcdr, mcar, set-mcdr!, set-mcar!
forcewith mutable pairs.
You want to make sure that your generator g does not fetch anything from the stream until g is invoked, otherwise for finite streams you could run off the end before you intended.
; create a generator g on stream s
(define g (make-gen s))
; access first two elements generated by s
(+ (g) (g))
mconsas representing edges between vertices in a graph. If
v2are vertices, then
(cons v1 v2)is the edge from
v2. For example, this list of edges
defines the graph:
( cons(v2 v1) cons(v1 v4) cons(v4 v3) cons(v3 v4) cons(v3 v1) )
(dfs g root)which does a depth-first traversal of the graph
g, starting at vertex
root, and returns a list of the vertices visited.
q-from-listthat takes a list and creates the queue with the same elements initially,
q-to-listthat takes a queue and creates a list containing the current elements of the queue.
|6. Week 4 - Jan 27|
CMPUT 325 Schedule / Version 2.31 2014-04-04