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

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -