From faa0fdf512c54691940e4385968c37f0374ae990 Mon Sep 17 00:00:00 2001 From: Chris Barker Date: Mon, 29 Nov 2010 15:54:13 -0500 Subject: [PATCH] edits --- zipper-lists-continuations.mdwn | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) 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 -- 2.11.0