
8 Apr
2010
8 Apr
'10
11:58 a.m.
If you don't mind choosing a different data type (always a good question to ask yourself in haskell) you could simply use your own nested lists.... data Nested a = One a | Nest [Nested a] deriving Show instance Functor Nested where fmap f (One x) = One (f x) fmap f (Nest xs) = Nest (map (fmap f) xs) mapN :: (a -> b) -> Nested a -> Nested b mapN = fmap test = fmap (+1) $ Nest [One 1, Nest [ One 2, One 3], One 4 , Nest [ Nest [One 6]] ] --yields test = Nest [One 2,Nest [One 3,One 4],One 5,Nest [Nest [One 7]]] On Apr 8, 2010, at 9:05 AM, beginners-request@haskell.org wrote:
Re: [Haskell-beginners] Map on Nested Lists