manip trees tweak
authorJim Pryor <profjim@jimpryor.net>
Mon, 13 Dec 2010 04:10:17 +0000 (23:10 -0500)
committerJim Pryor <profjim@jimpryor.net>
Mon, 13 Dec 2010 04:10:17 +0000 (23:10 -0500)
Signed-off-by: Jim Pryor <profjim@jimpryor.net>
manipulating_trees_with_monads.mdwn

index 7be7fd4..4f91bbb 100644 (file)
@@ -46,11 +46,11 @@ We'll be using trees where the nodes are integers, e.g.,
 
 Our first task will be to replace each leaf with its double:
 
-       let rec tree_map (t : 'a tree) (leaf_modifier : 'a -> 'b): 'b tree =
+       let rec tree_map (leaf_modifier : 'a -> 'b) (t : 'a tree) : 'b tree =
          match t with
            | Leaf i -> Leaf (leaf_modifier i)
-           | Node (l, r) -> Node (tree_map l leaf_modifier,
-                                  tree_map r leaf_modifier);;
+           | Node (l, r) -> Node (tree_map leaf_modifier l,
+                                  tree_map leaf_modifier r);;
 
 `tree_map` takes a tree and a function that transforms old leaves into
 new leaves, and maps that function over all the leaves in the tree,