[Haskell-beginners] Map on Nested Lists

matthew coolbeth mac01021 at engr.uconn.edu
Thu Apr 8 09:16:06 EDT 2010


I'm a beginner too but, if I am not wrong, then you will not be able to
write a function that can receive input of type [[a]] as well as input of
type [[[a]]].

Is that the behaviour that you have in mind?

On Thu, Apr 8, 2010 at 09:08, Ben Derrett <ben.derrett at googlemail.com>wrote:

> 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
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
>


-- 
mac
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20100408/f76a0a2d/attachment.html


More information about the Beginners mailing list