subSequence ( startIndex : Integer, endIndex : Integer ) : Sequence(T)
Returns a Sequence containing all elements of self between the positions 'startIndex' and 'endIndex'.
| Expression | Result |
|---|---|
| Sequence{'a', 'b', 'c', 'd'}->subSequence(2, 3) | Sequence{'b', 'c'} |
| Sequence{'a', 'b', 'c', 'd'}->subSequence(4, 4) | Sequence{'d'} |
Returns a smaller collection from start to stop.
subSequence(<start>, <stop>)
Please note that the index number is 1-based.
Example:
Sequence{1..20}->subSequence(10,15)
The expression above will return numbers 10, 11, 12, 13, 14, and 15.
If you supply index values outside the source collection, the result collection will be empty.
Note: Both startIndex and endIndex are inclusive - the element at endIndex is included in the result.
Examples:Single Element Extraction
Sequence{1, 2, 3, 4}->subSequence(3, 3)Result:
Sequence{3}When startIndex equals endIndex, it returns a sequence with that single element. Empty Collection
Sequence{}->subSequence(1, 5)Result:
Sequence{} (empty)Out of Bounds - Beyond End
Sequence{1, 2, 3}->subSequence(5, 10)Result:
Sequence{} (empty)When startIndex is beyond collection size, returns an empty sequence
