Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text 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 Go to next message
Tomas Balderas is currently offline Tomas Balderas
Messages: 46
Registered: July 2010
Member
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 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4098
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
Re: [Acceleo] How to generate a sequence (bag) of consecutive integers starting at 1 [message #813748 is a reply to message #813390] Mon, 05 March 2012 17:06 Go to previous message
Tomas Balderas is currently offline Tomas Balderas
Messages: 46
Registered: July 2010
Member
Thank you very much Edward, I never thought about the simplest solution. Need more experience in Acceleo.

Kindest regards.


/TB
Previous Topic:[XPAND] Generating More Than One Instance
Next Topic:how to get a list of import packages
Goto Forum:
  


Current Time: Sun Oct 26 03:00:25 GMT 2014

Powered by FUDForum. Page generated in 0.02018 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software