From b92c1aa7255f31ec081258f7fc6d5d0918602564 Mon Sep 17 00:00:00 2001 From: Chris Barker Date: Tue, 7 Dec 2010 12:42:25 -0500 Subject: [PATCH] edit --- assignment9.mdwn | 131 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 assignment9.mdwn diff --git a/assignment9.mdwn b/assignment9.mdwn new file mode 100644 index 00000000..2277a925 --- /dev/null +++ b/assignment9.mdwn @@ -0,0 +1,131 @@ +Using continuations to solve the same-fringe problem +---------------------------------------------------- + +The problem +----------- + +We've seen two solutions to the same fringe problem so far. +The problem, recall, is to take two trees and decide whether they have +the same leaves in the same order. + +
```+ ta            tb          tc
+ .             .           .
+_|__          _|__        _|__
+|  |          |  |        |  |
+1  .          .  3        1  .
+  _|__       _|__           _|__
+  |  |       |  |           |  |
+  2  3       1  2           3  2
+
+let ta = Node (Leaf 1, Node (Leaf 2, Leaf 3));;
+let tb = Node (Node (Leaf 1, Leaf 2), Leaf 3);;
+let tc = Node (Leaf 1, Node (Leaf 3, Leaf 2));;
+```
```+# let rec make_int_stream i = Next (i, fun () -> make_int_stream (i + 1));;