[Haskell-beginners] Map on Nested Lists

Ben Derrett ben.derrett at googlemail.com
Thu Apr 8 09:08:11 EDT 2010


Hi,
I'm trying to write a generalization of the map function that operates on
nested lists, e.g. [[a]] or [[[a]]]. (It should map all elements of type a
(not list) with f)

I was thinking of something along these lines:
mapN f *list of type [a] (where a is not a list type)* = map f l
mapN f l = (mapN f (head l)):(mapN f (tail l))

Any suggestions about how to go about this?

Many thanks,

Ben


-- 
Ben Derrett
Department of Mathematics
MIT Class of 2012
bderrett at mit.edu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20100408/e1f45eb6/attachment.html


More information about the Beginners mailing list