Skip to main content


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 09:17 Go to next message
graa is currently offline graaFriend
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 10:26 Go to previous messageGo to next message
wafaa is currently offline wafaaFriend
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 10:28 Go to previous messageGo to next message
wafaa is currently offline wafaaFriend
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 10:30]

Report message to a moderator

Re: while [message #534308 is a reply to message #534162] Tue, 18 May 2010 15:39 Go to previous messageGo to next message
zoro  is currently offline zoro Friend
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 11:06 Go to previous messageGo to next message
graa is currently offline graaFriend
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 17:28 Go to previous message
zoro  is currently offline zoro Friend
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: Thu Mar 28 21:34:11 GMT 2024

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

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

Back to the top