Slide 22
Slide 22 text
List comprehensions - Examples
Be L1 = [5, 8, 10, 29] and L2 = [9, 10, 4, 0, 73, 2]
Then:
●
[X || X <- L1, X > 6] → [8, 10, 29]
●
[{X, Y} || X <- L1, Y <- L2} is the cartesian
product L1xL2 → [{5,9}, {5, 10}, {5, 4}, …]
●
[X + 3 – Y || X <- L1, Y <- L2, Y < (X + 5)] → in
this case, the filter on Y references X