Stream operators
Unary stream operators
| Syntax | Description | Example |
|---|---|---|
<list>, made distinct
|
Eliminates duplicates and returns a unique list of elements. Elements in the resulting list appear in encounter order. If the list is empty or null, an empty list is returned. |
'the customers', made distinct
|
<list>, reversed
|
Reverses the sorting order of elements of a list. If the list is empty or null, an empty list is returned. |
'the customers', reversed
|
<list>, limited to the first <integer> elements
|
Returns the first n elements of a list, as specified by an integer. If the list is empty or null, an empty list is returned. |
'the customers', limited to the first 2 elements
|
<list>, limited to the number of first elements specified by <expression>
|
Returns the first n elements of a list, as specified by an expression. If the list is empty or null, an empty list is returned. |
'the customers', limited to the number of first elements specified by 'nbCustomers'
|
<list>, limited to the last <integer> elements
|
Returns the last n elements of a list, as specified by an integer. If the list is empty or null, an empty list is returned. |
'the customers', limited to the last 2 elements
|
<list>, limited to the number of last elements specified by <expression>
|
Returns the last n elements of a list, as specified by an expression. If the list is empty or null, an empty list is returned. |
'the customers', limited to the number of last elements specified by 'nbCustomers'
|
<list>, skipping the first <integer> elements
|
Discards the first n elements of a list, as specified by an integer. If the list is empty or null, an empty list is returned. |
'the customers', skipping the first 2 elements
|
<list>, skipping the number of first elements specified by <expression>
|
Discards the first n elements of a list, as specified by an expression. If the list is empty or null, an empty list is returned. |
'the customers', skipping the number of first elements specified by 'nbCustomers'
|
<list>, where [ elements called <variable> satisfy that ] <condition>
|
Returns the elements of a list that satisfy a specific condition. If the list is empty or null, an empty list is returned. |
'the customers', where the age of each customer is more than 18
|
<list>, limited to <type>
|
Returns the elements of a list that have a specific type. If the list is empty or null, an empty list is returned. |
'the pets', limited to dogs
|
<list>, sorted [ in ascending order | in descending order ]
|
Sorts the elements of a list in ascending or descending order. If no order is specified, the list is sorted in ascending order. If the list is empty or null, an empty list is returned. |
the amounts of 'the customers', sorted in descending order
|
<list>, sorted by <attribute> [ in ascending order | in descending order ] { then by <attribute> [ in ascending order | in descending order ] }
|
Returns the elements of a list in a given sort order. The elements can be returned in ascending or descending order. If no order is specified, the list is sorted in ascending order. If the list is empty or null, an empty list is returned. |
'the customers', sorted by name then by age in descending order
|
Binary stream operators
| Syntax | Description | Example |
|---|---|---|
<list>, concatenated with <list>
|
Concatenates two lists. If both lists are empty or null, an empty list is returned. |
'the existing customers', concatenated with 'the new customers'
|
<list>, combined with <list>
|
Combines two lists. The resulting list does not contain any duplicate element. If both lists
are empty or null, an empty list is returned. This operator is equivalent to |
'the existing customers', combined with 'the new customers'
|
<list>, deducting <list>
|
Removes elements of a list from another list. The resulting list does not contain any duplicate element. If the first list is empty or null, an empty list is returned. |
'the customers', deducting 'the blocklisted customers'
|
<list>, belonging to <list>
|
Returns a list of elements belonging to both of the specified lists. The resulting list does not contain any duplicate element. If one of the lists is empty or null, an empty list is returned. |
'the customers', belonging to 'the blocklisted customers'
|
Element selectors
| Syntax | Description | Example |
|---|---|---|
the first element in <list> [ defaulting to <expression> ]
|
Returns the first element in a list. If the list is empty or null and no default value is provided, an exception is thrown. |
the first element in 'the customers'
|
the last element in <list> [ defaulting to <expression> ]
|
Returns the last element in a list. If the list is empty or null and no default value is provided, an exception is thrown. |
the last element in 'the customers'
|
the element at position <integer> in <list> [ defaulting to <expression> ]
|
Returns the element that is at a specific position in a list, where the position is specified by an integer. If the list is null or the specified integer is negative or exceeds the number of elements in the list, an exception is thrown. Positions start at 1, not 0. |
the element at position 2 in 'the customers'
|
the element at the position corresponding to <integer> in <list> [ defaulting to <expression> ]
|
Returns the element that is at a specific position in a list, where the position is specified by an expression. If the list is null or the specified integer is negative or exceeds the number of elements in the list and no default value is provided, an exception is thrown. |
the element at the position corresponding to the index of the loan in 'the customers'
|
Stream constructors
These constructors are used to generate streams of integers. The following example shows a rule that adds ten items to a decision:
for each index, in [1 .. 10]
add a new item where the number is index to decision;
| Syntax | Description | Example |
|---|---|---|
the range from <integer> to <integer>
|
Returns a set of values contained between two integers. |
the range from 0 to the number of 'the
customers' - 1
|
[ <integer> .. <integer> ]
|
Returns a set of values contained between two integers. |
[ 1 .. 10 ]
|
|
or
|
Returns a set of values contained between two integers, including the lower bound and excluding the upper bound. |
[ 1 .. 10 )
|
|
or
|
Returns a set of values contained between two integers, excluding the lower bound and including the upper bound. |
( 1 .. 10 ]
|
|
or
|
Returns a set of values contained between two integers, excluding the lower bound and the upper bound. |
( 1 .. 10 )
|
Quantified conditions
| Syntax | Description | Example |
|---|---|---|
all elements [ called <variable> ] in <list> satisfy that <condition>
|
Returns true if all the elements in a list satisfy the specified condition.
If the list is empty or null, the returned value is true. |
all elements in 'the visitors' satisfy that the age of each customer is more than 30 and the gender of each customer is male
|
any element [ called <variable> ] in <list> satisfies that <condition>
|
Returns true if any element in a list satisfies the specified condition. If
the list is empty or null, the returned value is false. |
any element in 'the visitors' satisfies that the age of this customer is more than 30 and the gender of this customer is male
|
no element [ called <variable> ] in <list> satisfies that <condition>
|
Returns true if none of the elements in a list satisfy the specified
condition. If the list is empty or null, the returned value is true. |
no element in 'the visitors' satisfies that the age of this customer is more than 30 and the gender of this customer is male
|
Stream mapping operators
The mapping elements to and mapping elements called 'e' to operators transform each element of a sequence by applying a specified projection, producing a new sequence of transformed elements.
| Syntax | Description | Example |
|---|---|---|
<values>, mapping elements [ called <variable name> ] to <transformation> [,]
|
Transforms each element of a sequence according to the given expression. |
strings, mapping elements to each string to uppercase using the casing rules of "fr_FR"
|
| Transforms and limits the output to the first n elements of the sequence. |
strings, mapping elements to each string replacing all "foo" by 'myCarName', limited to the 10 first elements
|
|
| Assigns a name to each element for use within the transformation expression. |
strings, mapping elements called 's' to 's' replacing all "foo" by 'myCarName', limited to the 10 first elements
|
|
| Converts each string element to a number in the resulting sequence. |
strings, mapping elements to each string as number, limited to the 10 first elements
|