From d0a9dde6d449c9973b29704d7326ef978cba6da6 Mon Sep 17 00:00:00 2001 From: Jim Pryor Date: Wed, 1 Dec 2010 20:29:16 -0500 Subject: [PATCH] manip trees tweaks Signed-off-by: Jim Pryor --- manipulating_trees_with_monads.mdwn | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manipulating_trees_with_monads.mdwn b/manipulating_trees_with_monads.mdwn index 3b43c9a5..e7cccecd 100644 --- a/manipulating_trees_with_monads.mdwn +++ b/manipulating_trees_with_monads.mdwn @@ -265,10 +265,10 @@ We use the continuation monad described above, and insert the So for example, we compute: - # tree_monadize (fun a -> fun k -> a :: (k a)) t1 (fun t -> []);; + # tree_monadize (fun a -> fun k -> a :: k a) t1 (fun t -> []);; - : int list = [2; 3; 5; 7; 11] -We have found a way of collapsing a tree into a list of its leaves. Can you trace how this is working? Think first about what the operation `fun a -> fun k -> a :: (k a)` does when you apply it to a plain `int`, and the continuation `fun _ -> []`. +We have found a way of collapsing a tree into a list of its leaves. Can you trace how this is working? Think first about what the operation `fun a -> fun k -> a :: k a` does when you apply it to a plain `int`, and the continuation `fun _ -> []`. Then given what we've said about `tree_monadize`, what should we expect `tree_monadize (fun a -> fun k -> a :: k a` to do? The continuation monad is amazingly flexible; we can use it to simulate some of the computations performed above. To see how, first -- 2.11.0