Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » while
while [message #534162] Tue, 18 May 2010 05:17 Go to next message
graa is currently offline graa
Messages: 42
Registered: April 2010
Member
Hi,
how I can express in ocl:
while (w different from empty sequence) do?
thanks
Re: while [message #534190 is a reply to message #534162] Tue, 18 May 2010 06:26 Go to previous messageGo to next message
wafaa is currently offline wafaa
Messages: 163
Registered: January 2010
Location: Egypt
Senior Member
Quote:

The "for" statement enables to define iterative imperative computations. A "for" statement has to conform to the following syntax:
for(iterator in collection) {
statements
}
The "for" statement defines an iteration variable (iterator) that will iterate over the different elements of the reference collection. For each of these elements, the sequence of statements contained by the "for" statement will be executed.
The following example, also related to the MMPerson metamodel (see Appendix B) illustrates the use of the "for" imperative statement:
for(p in MMPerson!Person.allInstances()) {
if(p.gender = #male)
thisModule.men->including(aPerson);
else
thisModule.women->including(aPerson);
}



accordingly u should do some thing like this

for(i in K) -- where k is ur sequence
{
if i <> sequence{}
then
............
else
.........
end if
}
Re: while [message #534191 is a reply to message #534190] Tue, 18 May 2010 06:28 Go to previous messageGo to next message
wafaa is currently offline wafaa
Messages: 163
Registered: January 2010
Location: Egypt
Senior Member
I liked this tutorial
hope u too
http://sosym.dcs.kcl.ac.uk/events/mtip05/submissions/jouault _kurtev__transforming_models_with_atl.pdf

[Updated on: Tue, 18 May 2010 06:30]

Report message to a moderator

Re: while [message #534308 is a reply to message #534162] Tue, 18 May 2010 11:39 Go to previous messageGo to next message
zoro  is currently offline zoro
Messages: 26
Registered: April 2010
Junior Member
collection->iterate(e; result: Type=<expression> | <expression-with-e-and-result>)
Re: while [message #534791 is a reply to message #534308] Thu, 20 May 2010 07:06 Go to previous messageGo to next message
graa is currently offline graa
Messages: 42
Registered: April 2010
Member
thanks

but,what means <expression-with-e-and-result>?
Re: while [message #534937 is a reply to message #534162] Thu, 20 May 2010 13:28 Go to previous message
zoro  is currently offline zoro
Messages: 26
Registered: April 2010
Junior Member
Quote:
The variable element is the iterator variable. The resulting value is accumulated in the variable result, which is also called the accumulator. The accumulator gets an initial value, given by the expression after the equal sign. None of the parameters is optional
The result of the iterate operation is a value obtained by iterating over all elements in a collection. For each successive element in the source collection, the body expression (<expression-with-element-and-result>) is calculated using the previous value of the result variable. A simple example of the iterate operation is given by the following expression, which results in the sum of the elements of a set of integers:



Set{1,2,3}->iterate( i: Integer, sum: Integer = 0 | sum + i )

Previous Topic:[QVTO] Inline Object Creation
Next Topic:1..* transformation in QVT
Goto Forum:
  


Current Time: Fri Aug 01 02:01:55 EDT 2014

Powered by FUDForum. Page generated in 0.01682 seconds