From: Chris Barker Date: Tue, 7 Dec 2010 17:42:25 +0000 (-0500) Subject: edit X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=commitdiff_plain;h=b92c1aa7255f31ec081258f7fc6d5d0918602564 edit --- 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));;