2
0
Fork 0
mirror of https://github.com/MartinThoma/LaTeX-examples.git synced 2025-04-26 06:48:04 +02:00
LaTeX-examples/documents/Programmierparadigmen/scripts/haskell/tree-map.hs

5 lines
175 B
Haskell
Raw Normal View History

2014-03-11 13:58:42 +01:00
data Tree t = Node t [Tree t]
reduceT :: (t -> t -> t) -> Tree t -> t
reduceT f (Node x []) = x
reduceT f (Node x [y]) = f x y
reduceT f (Node x (y:ys)) = reduceT f (f x y) ys