week11 tweaks
[lambda.git] / zipper-lists-continuations.mdwn
index de13fe9..7687e65 100644 (file)
@@ -852,6 +852,28 @@ let rec t1 (z:char list_zipper) =
 Note that this implementation enforces the evaluate-leftmost rule.
 Task 1 completed.
 
+One way to see exactly what is going on is to watch the zipper in
+action by tracing the execution of `t1`.  By using the `#trace`
+directive in the Ocaml interpreter, the system will print out the
+arguments to `t1` each time it is (recurcively) called:
+
+<pre>
+# #trace t1;;
+t1 is now traced.
+# t1 ([], ['a'; 'b'; 'S'; 'e']);;
+t1 <-- ([], ['a'; 'b'; 'S'; 'e'])
+t1 <-- (['a'], ['b'; 'S'; 'e'])
+t1 <-- (['b'; 'a'], ['S'; 'e'])
+t1 <-- (['b'; 'a'; 'b'; 'a'], ['e'])
+t1 <-- (['e'; 'b'; 'a'; 'b'; 'a'], [])
+t1 --> ['a'; 'b'; 'a'; 'b'; 'e']
+t1 --> ['a'; 'b'; 'a'; 'b'; 'e']
+t1 --> ['a'; 'b'; 'a'; 'b'; 'e']
+t1 --> ['a'; 'b'; 'a'; 'b'; 'e']
+t1 --> ['a'; 'b'; 'a'; 'b'; 'e']
+- : char list = ['a'; 'b'; 'a'; 'b'; 'e']
+</pre>
+
 The nice thing about computations involving lists is that it's so easy
 to visualize them as a data structure.  Eventually, we want to get to
 a place where we can talk about more abstract computations.  In order