Explanation of specific comprehension of a list in Haskell
1 answer
Your predicate is "z = x + y for all odd z". If you "unroll" the stream:
z = predicate and y (x), so for:
x = 1,2
y (1) = 1,2,3
y (2) = 2,3
Based on a combination of values โโfiltered by the predicate:
x+y <= filter(z)
1+1 = 2 NO
1+2 = 3 OK
1+3 = 4 NO
2+2 = 4 NO
2+3 = 5 OK
so the ok answers match x = 1 and y = 2 and x = 2 and y = 3 => [(1,2), (2,3)]
+4
source to share