haskell - What does the treemp function do, here? -
what treemp function does, here? input , output correspond to?
import data.word import data.char import data.list import system.environment data tree = leaf | root [tree a] deriving (eq, show) treemp f (leaf a) = leaf $ f treemp f (root ts) = root (f a) $ map (treemp f) ts t0 = root 0 [t1,t2,t3,t4,t5] t1 = leaf 1 t2 = root 2 [leaf 6, leaf 7, root 11 [leaf 12, leaf 13]] t3 = root 3 [leaf 8, leaf 9] t4 = root 4 [leaf 10] t5 = leaf 5
it looks me fmap definition tree. given f :: -> b, apply f every a in tree a (in leaf , root, , recursively each tree in root), returning tree b
Comments
Post a Comment