[Haskell-beginners] Applying a function to two lists
Matt Williams
matt.williams45.mw at gmail.com
Sat Apr 23 08:50:32 UTC 2016
Thanks a lot for this.
Just to clarify (and ignoring the flip, which I can solve by rewriting the
checkNum function) - is this an example of currying?
M
On Fri, 22 Apr 2016 22:30 Francesco Ariis, <fa-ml at ariis.it> wrote:
> On Fri, Apr 22, 2016 at 10:20:19PM +0100, Matt Williams wrote:
> > I am looking for something like:
> >
> > list1 = [1,2,3,4,5,6]
> > list2 = [1,2,3,4,5,6]
> >
> > map checkNum list1 list2
> >
> > to return:
> >
> > [(1,[1]),(2[3,4,5]),(6,[3])
> >
> > (I have tried to simplify this a little, so my apologies if it looks
> > pointless - the real function is useful)
> >
> > Any help would be appreciated.
> >
> > Matt
>
> Hey Matt,
> if what you want is
>
> [checkNum 1 list2, checkNum 2 list2, etc.]
>
> then
>
> map (flip checknum list2) list1
>
> is what you want (flip signature being :: (a -> b -> c) -> b -> a -> c)
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20160423/4c14237d/attachment.html>
More information about the Beginners
mailing list