|
Re: Looking for a sample recursive hepler? [message #88853 is a reply to message #88839] |
Sat, 23 August 2008 14:35 |
Alfons Laarman Messages: 71 Registered: July 2009 |
Member |
|
|
Hi,
'i'.repeat(5) --> 'iiiii'
helper context String def : repeat(i : Integer) : String =
self.repeatRec('', i, 0);
helper context String def : repeatRec(acc : String, n : Integer, c :
Integer) : String =
if c < n then self.repeatRec(acc+self, n, c+1) else acc endif;
This gets all EFeatures of an EClass, it walks over the inheritance
hierarchy:
helper def : allFeatures(t : OclType) : Set(OclAny) =
t.eStructuralFeatures->union(t.eSuperTypes->collect(st |
thisModule.allFeatures(st))->flatten()->asSet());
Regards,
Alfons
"Zhuang" <zhuangguotao@hotmail.com> schreef in bericht
news:8f0bfacf726538b0aee697779f1f507d$1@www.eclipse.org...
> hello,
>
> I want to look for a sample recursive hepler.
> Pls everyone help me.
>
> Thanks!
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.02677 seconds