up previous next
2.5.2 List Constructors
These operators create new lists.
A..B
[A,B,C,...]
[X in L: LIST | B: BOOL]: LIST
[E:expression | X in L]: LIST
[E:expression | X in L: LIST and B: BOOL]: LIST
A..B creates the list of integers from A to B , both ends are included.

[A,B,C,...] makes a list containing A , B , C and so on, in that order.

[X in L | B] makes a list of those elements in L for which condition B is true.

[E | X in L] evaluates the expression E for each X in L , and collects the results in a new list.

[E | X in L and B] evaluates the expression E for each X in L which satisfies the condition B , and collects the results in a new list.

Example
/**/  [];  --> empty list
[]
/**/  1..4;
[1, 2, 3, 4]
/**/  [3,1,4,2];
[3, 1, 4, 2]
/**/  [N in 1..10 | IsPrime(N)];
[2, 3, 5, 7]
/**/  [N^2 | N in 1..4];
[1, 4, 9, 16]
/**/  [N^2 | N in 1..10 and IsPrime(N)];
[4, 9, 25, 49]