I am trying to generate all possibles combinations from two lists and then only return those that match the lambda function. So I currently have the following code:
func :: [a] -> [b] -> ((a, b) -> Bool) -> [(a, b)]
func xs ys f = filter f (tup)
where
tup = concat(map (\x -> map (\y -> (x,y))ys) xs)
Currently I am able to generate all the possible combinations, but the filtering won't work.
Error for the input : func [1,2,3] [4,5] (\ a b -> a+b > 6)
• Couldn't match expected type ‘Bool’ with actual type ‘(a, b) -> Bool’
• The lambda expression ‘\ a b -> a + b > 7’ has two value arguments, but its type ‘(a, b) -> Bool’ has only one
How can I solve this?
I tried to use map instead of filter, but that did not work as well.
func [1, 2, 3] [4, 5] (\(a, b) -> a+b > 6)instead.