[Haskell-beginners] Applying a function to two lists
Matt Williams
matt.williams45.mw at gmail.com
Fri Apr 22 21:20:19 UTC 2016
Dear List,
I am stuck.
I have a function that needs to apply each item of one list to every
element of the second list in turn.
So far, I have this function:
checkNum :: Int -> [Int] -> (Int,[Int])
checkNum a b = (a,filter (check a) $ b)
which implements what I need, but I now need to apply it to every
element of the first list.
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
More information about the Beginners
mailing list