manip trees tweak
[lambda.git] / 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:
 
 
 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)
          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,
 
 `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,