open list data mutable node a = Node { content : a; visited : bool; neighbors: list dynamic; } data mutable graph a = Graph { roots : list dynamic; } adopts node a val g : graph int = let n = Node { content = 10; visited = false; neighbors = (); } in let ns = Cons { head = n; tail = Nil } in n.neighbors <- ns; let g : graph int = Graph { roots = ns } in give n to g; g val dfs [a, p : perm] ( g: graph a, f: (a | p) -> () | p) : () = let rec visit (n: dynamic | g @ graph a * p) : () = take n from g; if n.visited then give n to g else begin n.visited <- true; f n.content; let neighbors = n.neighbors in give n to g; iter (neighbors, visit) end in iter (g.roots, visit) (* Local Variables: compile-command: "mezzo graph.mz" End: *)