-
Notifications
You must be signed in to change notification settings - Fork 8
Closed
Description
The nested comprehension isn't correct:
*Main> [(x,y) | x <- [1,2], y <- [3,4]]
[(1,3),(1,4),(2,3),(2,4)]
nestedComprehension xs ys = concat [[(x, y) | x <- xs] | y <- ys]
*Main> nestedComprehension [1,2] [3,4]
[(1,3),(2,3),(1,4),(2,4)]
is sadly wrong. The x <- xs
and y <- ys
need to be switched:
nestedComprehension xs ys = concat [[(x, y) | y <- ys] | x <- xs]
*Main> nestedComprehension [1,2] [3,4]
[(1,3),(1,4),(2,3),(2,4)]
Metadata
Metadata
Assignees
Labels
No labels