I am trying to apply sum using id function while giving input to program.but i am with below. any guidance is much appreciated.
data Tree a = Leaf a | Node (Tree a) a (Tree a) deriving (Eq, Show)
reduce_tree :: Tree a -> (a -> b) -> (b -> a -> b -> b) -> b
reduce_tree (Leaf v) = [v]
reduce_tree (Node left root right) = reduce_tree left ++ [root] ++ reduce_tree right
input as follows:
ghci> reduce_tree (VNode (VLeaf 1) 2 (VNode (VLeaf 3) 4 (VLeaf 5)))
id sum
where sum t1 v t2 = t1 + v + t2
15