Examples
?{ (a,b) | a ? x, b ? y } for each b in y do
?{ (a,b) | a ? [1,2,3], b ? {4,5} }
= { (1,4), (1,5), (2,4), (2,5), (3,4), (3,5) }
+{ a | a ? [1,2,3], a ? 2 }
Notes:
This is an example of a comprehension that contains two generators but no filter. It performs the following computation: for each element a of x and for each element b of y, insert the pair (a,b) to the resulting set, which is initially empty. For example, if x is the list [1,2,3] and y is the bag {4,5}, the result is a set with 6 pairs. Another example is the above comprehension that filters out of the list [1,2,3] all the elements a less than 2 and adds together the rest.