From 6debd883b7ee5c9125743a23d05e997b9188f90e Mon Sep 17 00:00:00 2001 From: Jim Pryor Date: Sun, 12 Dec 2010 23:10:17 -0500 Subject: [PATCH] manip trees tweak Signed-off-by: Jim Pryor --- manipulating_trees_with_monads.mdwn | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/manipulating_trees_with_monads.mdwn b/manipulating_trees_with_monads.mdwn index 7be7fd49..4f91bbbb 100644 --- a/manipulating_trees_with_monads.mdwn +++ b/manipulating_trees_with_monads.mdwn @@ -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, -- 2.11.0