[Haskell-beginners] Applying a function to two lists

Francesco Ariis fa-ml at ariis.it
Fri Apr 22 21:26:40 UTC 2016


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)


More information about the Beginners mailing list