OCLOperators subSequence
No edit summary
(Updated Edited template to July 12, 2025.)
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<message>Write the content here to display this box</message>
=== subSequence ( startIndex : Integer, endIndex : Integer ) : Sequence(T) ===
Returns a Sequence containing all elements of ''self'' between the positions 'startIndex' and 'endIndex'.
{| class="wikitable"
!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.
Returns a smaller collection from start to stop.
  subSequence(<start>, <stop>)
  subSequence(<start>, <stop>)
Line 8: Line 22:


If you supply index values outside the source collection, the result collection will be empty.
If you supply index values outside the source collection, the result collection will be empty.
[[Category:OCLOperators]]
[[Category:OCL Collection Operators]]
{{Edited|July|12|2025}}

Latest revision as of 05:58, 20 January 2025

This page was created by Alexandra on 2017-08-13. Last edited by Edgar on 2025-01-20.

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.

MDriven Chat

How would you like to chat today?

Setting up your conversation…

This may take a few moments