Navigation
Synopsis A set comprehension generates a set value.
Syntax { Exp1, Exp2, ... | Gen1, Gen2, ... }
Types
Exp1 Exp2 ... { Exp1, Exp2, ... | Gen1, Gen2, ... }
T1 T2 ... set[ lub( T1, T2, ... ) ]
Description A set comprehension consists of a number of contributing expressions Exp1, Exp2, ... and a number of generators Gen1, Gen2, Gen3, ... that are evaluated as described in Expressions/Comprehensions.
Examples
rascal>{ N * N | int N <- [0 .. 10]};
set[int]: {1,9,16,25,0,64,4,36,49,81}
rascal>{ N * N | int N <- [0 .. 10], N % 3 == 0};
set[int]: {0,36,9,81}

Questions
Question [1].
The type of { N + 1 | int N <- [3 .. 9] } is

Question [2].
{ N + 1 | int N <- [4 .. 10] } == 

Question [3].
{ 2 * N | int N <- {19} } == 

Question [4]. Complete this comprehension:
{  | int N <- {-7, 12, -18, -2} } == {11,-19,-8,-3}



Is this page unclear, or have you spotted an error? Please add a comment below and help us to improve it. For all other questions and remarks, visit ask.rascal-mpl.org.