I am reading through Bird and Wadler's nice book in Functional programming and trying to solve the exercises in Haskell.
The chapter on Lists has a section which says that any list comprehension
can be implemented in terms of map
, filter
and concat
and subsidiary functions which one might need for map
I am having trouble implementing the following expression in terms of these building blocks.
[(x,y) | x<- xs, y<- ys]
How would one use map and filter for this?
I got as far as doing
concat [ map (\ a -> (a,x)) ys | x<-xs ]
I suspect we have to use currying cleverly here, but i can't seem to figure it out.