I hope anyone can help me. I am assigning numbers as names of input pins in an action in an activity diagram. From this collection of input pins I am successfully computing a sequence (or bag) of integers (instances of Integer). What I need to determine now is whether such sequence (or bag) equals the sequence {1, 2, 3, 4, ... , n}.

My strategy is to generate the sequence {1, 2, 3, 4, ... , n} by using an expression like

Integer.allInstances()

->collect(i: Integer | i <= [an expression to compute the value of n])

->asBag()

and then compare this bag to the one I computed from the input pins.

My problem is that the expression that computes {1, 2, 3, 4, ... , n} illustrated above does not seem to work.

Any idea to generate the sequence of integers {1, 2, 3, 4, ... , n}? Any idea to determine if a sequence of integers equals the sequence {1, 2, 3, 4, ... , n} in a more elegant way?

Thank you very much.

UPDATE: I used select instead of collect in the expresion and it did not work either:

Integer.allInstances()

->select(i: Integer | i <= [an expresion to compute the value of n])

I get nothing when trying to generate text from the result of this expression

/T]]>

Try Sequence{1..n}.

Regards

Ed Willink

On 05/03/2012 01:34, Tomas Balderas wrote:

> Hello

>

> I hope anyone can help me. I am assigning numbers as names of input

> pins in an action in an activity diagram. From this collection of

> input pins I am successfully computing a sequence (or bag) of integers

> (instances of Integer). What I need to determine now is whether such

> sequence (or bag) equals the sequence {1, 2, 3, 4, ... , n}.

>

> My strategy is to generate the sequence {1, 2, 3, 4, ... , n} by using

> an expresion like

>

> Integer.allInstances()

> ->collect(i: Integer | i <= [an expresion to compute the value of n])

> ->asBag()

>

> and then compare this bag to the one I computed from the input pins.

>

> My problem is that the expresion that computes {1, 2, 3, 4, ... , n}

> illustrated above does not seem to work.

>

> Any idea to generate the sequence of integers {1, 2, 3, 4, ... , n}?

> Any idea to determine if a sequence of integers equals the sequence

> {1, 2, 3, 4, ... , n} in a more elegant way?

>

> Thank you very much.

>

> /T]]>

Kindest regards.]]>