Skip to main content



      Home
Home » Archived » M2M (model-to-model transformation) » while
while [message #534162] Tue, 18 May 2010 05:17 Go to next message
Eclipse UserFriend
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
Eclipse UserFriend
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
Eclipse UserFriend
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] by Moderator

Re: while [message #534308 is a reply to message #534162] Tue, 18 May 2010 11:39 Go to previous messageGo to next message
Eclipse UserFriend
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
Eclipse UserFriend
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
Eclipse UserFriend
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: Tue Jun 24 16:46:41 EDT 2025

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

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

Back to the top