Container/Visitor/Iterator (II)

data Tree a 
   = Leaf
   | Node { key :: a
          , left :: Tree a, right :: Tree a 
          }
tmap :: ( a -> b ) -> ( Tree a -> Tree b )
tmap f t = case t of
    Leaf -> Leaf
    Node {} -> 
        Node { key   = f (key t)
             , left  = tmap f (left t)
             , right = tmap f (right t)
             }



Johannes Waldmann 2004-11-30