X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=blobdiff_plain;f=using_continuations_to_solve_same_fringe.mdwn;h=1c980a4b806474007cf4d5e6467b665e6a78f4e1;hp=b65add60226504e567c786d83e369830abb07731;hb=2cf860e245af53cbd58f88575f6f9f3a9884be40;hpb=2dba81fca7c1d2dcfb4fdff6f55c74c8cf795470;ds=sidebyside
diff --git a/using_continuations_to_solve_same_fringe.mdwn b/using_continuations_to_solve_same_fringe.mdwn
index b65add60..1c980a4b 100644
--- a/using_continuations_to_solve_same_fringe.mdwn
+++ b/using_continuations_to_solve_same_fringe.mdwn
@@ -58,15 +58,15 @@ the thunk by applying it to the unit:
# let rec make_int_stream i = Next (i, fun () -> make_int_stream (i + 1));;
-val make_int_stream : int -> int stream =
+val make_int_stream : int -> int stream = [fun]
# let int_stream = make_int_stream 1;;
-val int_stream : int stream = Next (1, ) (* First element: 1 *)
+val int_stream : int stream = Next (1, [fun]) (* First element: 1 *)
# match int_stream with Next (i, rest) -> rest;;
-- : unit -> int stream = (* Rest: a thunk *)
+- : unit -> int stream = [fun] (* Rest: a thunk *)
(* Force the thunk to compute the second element *)
# (match int_stream with Next (i, rest) -> rest) ();;
-- : int stream = Next (2, )
+- : int stream = Next (2, [fun])

You can think of `int_stream` as a functional object that provides
@@ -115,11 +115,14 @@ Notice the forcing of the thunks in the recursive call to
- : bool = false
-Now, this implementation is a bit silly, since in order to convert the
-trees to leaf streams, our tree_monadizer function has to visit every
-node in the tree. But if we needed to compare each tree to a large
-set of other trees, we could arrange to monadize each tree only once,
-and then run compare_streams on the monadized trees.
+Now, you might think that this implementation is a bit silly, since in
+order to convert the trees to leaf streams, our tree_monadizer
+function has to visit every node in the tree, so we'd have to traverse
+the entire tree at some point. But you'd be wrong: part of what gets
+suspended in the thunking of the stream is the computation of the rest
+of the monadized tree. Proving this claim requires adding print
+statements (or other tracing technology) within the tree monadizer
+function.
By the way, what if you have reason to believe that the fringes of
your trees are more likely to differ near the right edge than the left