[Acceleo] Removing duplicate in collection [message #897655] |
Tue, 24 July 2012 23:13 |
Wagner de Andrade Perin Messages: 2 Registered: July 2012 |
Junior Member |
|
|
Hi.
I am a beginner in Acceleo and have a "simple" problem.
I write this code:
primeiraOrdem(Conceito, Consulta) :-
[for (elemento : Componentes | aMapaConceitual.elementos->sortedBy(descricao))]
[if (elemento.oclIsTypeOf(Relacao))]
[elemento.descricao/](Conceito, Consulta),
[/if]
[/for]
And i get this results:
primeiraOrdem(Conceito, Consulta) :-
e(Conceito, Consulta),
podeestar(Conceito, Consulta),
podeser(Conceito, Consulta),
quandoesta(Conceito, Consulta),
quandoesta(Conceito, Consulta),
tem(Conceito, Consulta),
tem(Conceito, Consulta).
My question is: "How can I remove the lines that are worded "duplicate" (case of 'quandoesta' and 'tem')?"
I tried everything I could think but not got successful.
Excuse my poor English.
Thank you already.
|
|
|
Re: [Acceleo] Removing duplicate in collection [message #897671 is a reply to message #897655] |
Wed, 25 July 2012 05:06 |
Ed Willink Messages: 7681 Registered: July 2009 |
Senior Member |
|
|
Hi
Set is the usual way to force uniqueness, with isUnique() helpful in
more complicated scenarios.
You can just change to loop over your names reduced to a set of their values
[for (descricao: String|
aMapaConceitual.elementos->select(oclIsTypeOf(Relacao)).descricao->asSet()->sortedBy(descricao
| descricao))]
[descricao/](Conceito, Consulta),
[/for]
oclIsKindOf is generally better than oclIsTypeOf, in which case filter()
would be better. (In Juno OCL adds selectByType and selectByKind as well).
Regards
Ed Willink
On 25/07/2012 00:13, Wagner de Andrade Perin wrote:
> Hi.
>
> I am a beginner in Acceleo and have a "simple" problem.
>
> I write this code:
>
> primeiraOrdem(Conceito, Consulta) :-
> [for (elemento : Componentes |
> aMapaConceitual.elementos->sortedBy(descricao))]
> [if (elemento.oclIsTypeOf(Relacao))]
> [elemento.descricao/](Conceito, Consulta),
> [/if]
> [/for]
>
> And i get this results:
> primeiraOrdem(Conceito, Consulta) :-
> e(Conceito, Consulta),
> podeestar(Conceito, Consulta),
> podeser(Conceito, Consulta),
> quandoesta(Conceito, Consulta),
> quandoesta(Conceito, Consulta),
> tem(Conceito, Consulta),
> tem(Conceito, Consulta).
>
> My question is: "How can I remove the lines that are worded
> "duplicate" (case of 'quandoesta' and 'tem')?"
>
> I tried everything I could think but not got successful.
>
> Excuse my poor English.
>
> Thank you already.
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03660 seconds