Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » collect equivalent for one element
collect equivalent for one element [message #1752332] Sat, 21 January 2017 18:05 Go to next message
Banafsheh A is currently offline Banafsheh AFriend
Messages: 262
Registered: July 2016
Senior Member
I am new in OCL. How can I write OCL expression below for one element?

s.source.elements -> collect (s|thisModule.CreateMatchClass(s))

[Updated on: Sat, 21 January 2017 18:06]

Report message to a moderator

Re: collect equivalent for one element [message #1752333 is a reply to message #1752332] Sat, 21 January 2017 19:01 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5573
Registered: July 2009
Senior Member
Hi

I have no idea, since I cannot understand your question.

Once you learn to express your intended computation in a clear (declarative) way you will find that transliteration into OCL is quite straightforward. Practice your exposition.

Regards

Ed Willink
Re: collect equivalent for one element [message #1752346 is a reply to message #1752333] Sun, 22 January 2017 18:45 Go to previous messageGo to next message
Banafsheh A is currently offline Banafsheh AFriend
Messages: 262
Registered: July 2016
Senior Member
In other words, I don't understand which elements does the above code collect?
Since "collect" is used when we have more than one element, if I have one element (instead of elements), what changes occure to "-> collect (s|thisModule.CreateMatchClass(s))" part of that expression?
Re: collect equivalent for one element [message #1752348 is a reply to message #1752346] Sun, 22 January 2017 19:12 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5573
Registered: July 2009
Senior Member
Hi

collect is for multiple elements.

If you only have one element why would you want to collect all one of it? For comparison, if you have a Java loop counter, why would you declare it as "int[] i" rather than "int i", or why would you want to wrap a single calculation in a loop?

You need to express your intent clearly.

Regards

Ed Willink
Re: collect equivalent for one element [message #1752371 is a reply to message #1752348] Mon, 23 January 2017 06:36 Go to previous messageGo to next message
Banafsheh A is currently offline Banafsheh AFriend
Messages: 262
Registered: July 2016
Senior Member
For one element is below code true?
s.source.thisModule.CreateMatchClass(s)
Re: collect equivalent for one element [message #1752384 is a reply to message #1752371] Mon, 23 January 2017 09:24 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5573
Registered: July 2009
Senior Member
Hi

No idea.

What is "s"?
What is "source"?
What is "thisModule"?
What is "CreateMatchClass"?

See https://wiki.eclipse.org/OCL/ForumNetiquette

Regards

Ed Willink

Re: collect equivalent for one element [message #1752440 is a reply to message #1752384] Mon, 23 January 2017 18:51 Go to previous message
Banafsheh A is currently offline Banafsheh AFriend
Messages: 262
Registered: July 2016
Senior Member
I get my answer in another site. thanks for your time.
Previous Topic:Of surname propagation, another nest.
Next Topic:Problem in navigating references
Goto Forum:
  


Current Time: Wed Jan 17 05:43:03 GMT 2018

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

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