Home » Modeling » M2T (modeltotext transformation) » [Acceleo] How to generate a sequence (bag) of consecutive integers starting at 1(Need to determine if a bag of integers retrieved from modeling elements equals the series 1, 2, 3, ...)
[Acceleo] How to generate a sequence (bag) of consecutive integers starting at 1 [message #813218] 
Mon, 05 March 2012 01:34 

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 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
/TB
[Updated on: Mon, 05 March 2012 03:18] Report message to a moderator



Re: [Acceleo] How to generate a sequence (bag) of consecutive integers starting at 1 [message #813390 is a reply to message #813218] 
Mon, 05 March 2012 07:47 
Ed Willink Messages: 4155 Registered: July 2009 
Senior Member 


Hi
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


 
Goto Forum:
Current Time: Sat Nov 29 06:45:08 GMT 2014
Powered by FUDForum. Page generated in 0.01649 seconds
