[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.m2m] Re: [ATL] Iterative expression

Hello,

I didn't find a way. But this helpers may be useful:

-- returns a sequence of integers from self to end
helper context Integer def: To(end:Integer):Sequence(Integer) =
	if self=end then Sequence{self}
	else
		if self>end then self->To(end+1)->including(end)
		else self->To(end-1)->including(end)
		endif
	endif;

-- returns a sequence of numbers from 0 to self
helper context Integer def: count():Sequence(Integer) =
	0->To(self);

With that helpers you can create sequences of integers to iterate over.
But I guess you won't get high performance with that, especially for high numbers.


Greetings,
Max

Hello,
I've a questions. I would want iterate on a variable of integer type and not on an instance. It's possible?
If it's possible, which iterative expression I do use?
Sorry for my english.


Thanks

Lu