Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Polarsys » M2Doc » Recursive Functions(Recurse through the model structure)
Recursive Functions [message #1828404] Tue, 09 June 2020 09:15 Go to next message
James Tooke is currently offline James TookeFriend
Messages: 9
Registered: January 2020
Junior Member
Is it possible to write recursive functions in M2Doc?

I would like to structure part of my output document based on the functional breakdown of my system.

e.g.

Top Level Function
- Child Function 1
- Child of Child Function 1
- Child Function 2
- Child of Child Function 2
- Child of Child Function 2

The best way I think of to achieve this would be a recursive function. But I'm not sure if this is possible or how I might do it?

The alternative would be to hardcode a few levels of recursion in the template using for loops and if statements. But this would set a hard limit on the number of levels the functions could be decomposed into, which is why I was trying to avoid it.
Re: Recursive Functions [message #1828409 is a reply to message #1828404] Tue, 09 June 2020 10:31 Go to previous messageGo to next message
Yvan Lussaud is currently offline Yvan LussaudFriend
Messages: 63
Registered: July 2009
Member
It's possible using template constructs. It's basically a function you can call, and you can call it recursively.

You can find a complete exemple here.
Re: Recursive Functions [message #1831137 is a reply to message #1828404] Wed, 12 August 2020 09:31 Go to previous message
Ida Dahl is currently offline Ida DahlFriend
Messages: 5
Registered: August 2020
Junior Member
You could also use the closure operation from ocl to create recursive expressions. I have used it to create the kind of structure you are looking for for my logical components using the code

{m:for subLogicalComponent | RootLogicalComponent.eContents(la::LogicalComponent)->closure(logicalComponent | logicalComponentc.eContents(la::LogicalComponent))}
<code or text to print for each subLogicalComponent goes here>
{m:endfor}

I have renamed the variables for you to make them explicit. Hopefully you find this helpful!

Ida
Previous Topic:Remove HTML balises from generated document
Next Topic:M2Doc detected bugs and errors
Goto Forum:
  


Current Time: Wed Dec 07 13:19:41 GMT 2022

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

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

Back to the top