[Haskell-beginners] Traversing generic trees

Imants Cekusins imantc at gmail.com
Wed Jul 22 23:10:12 UTC 2015


how about this:


data Tree a = L a | N [Tree a] deriving Show


l::a -> Tree a
l = L

n::a -> Tree a
n x = N [L x]

m::(a->Tree a) ->[a]-> Tree a
m f list = N $ f <$> list


run it like this:
m l [2,3]
m n [2,3]

any good?


More information about the Beginners mailing list