From: Chris Barker Date: Mon, 29 Nov 2010 20:54:13 +0000 (-0500) Subject: edits X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=commitdiff_plain;h=faa0fdf512c54691940e4385968c37f0374ae990 edits --- diff --git a/zipper-lists-continuations.mdwn b/zipper-lists-continuations.mdwn index de13fe94..7687e657 100644 --- a/zipper-lists-continuations.mdwn +++ b/zipper-lists-continuations.mdwn @@ -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: + +
+# #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']
+
+ 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