How to compare collections? - Forum - Corticon - Progress Community

How to compare collections?

 Forum

How to compare collections?

This question is answered

I have a business rule based on the equality of two collections.
The condition A=B doesn't do the job, for = is in this case an assignment operator.
So I tried to implement the condition with two conditions:
A->forAll(B->exists(A.nr=B.nr)) and
B->forAll(A->exists(B.nr=A.nr)), but nesting quantifiers doen't seem possible, the error message is 'mismatched brackets'.

Does anyone know how to solve this? Thanks.

Verified Answer
  • Hi Gertjan,

    My previous answer was incorrect, so I deleted it,

    A->exists(A.nr=B.nr) and B->exists(A.nr=B.nr) does the trick together with the Corticon inference mechanism.

    Thanks,

    Tineke

All Replies
  • Hi Tineke,

    Are the 2 collections based on 2 different entities? So you have A.Nr and B.Nr as the attributes that need to be compared? Or do you have 1 entity with 2 aliasses A and B?

    -Gertjan

  • Hi Gertjan, yes

    nr is the identifying attribute of the entities in both collections.

    The entities in the collections are the same.

    Tineke  

  • Does this do the trick for you?

    A.Nr = B.Nr

    A <> B

  • Hi Gertjan, my question was a little foolish. Due to the inference mechanisme of Corticon I didn't need the combination of quantifiers. I solved it with:

    A->forAll(A.nr=B.nr) and

    B->forAll(B.nr=A.nr),

    I guess your solution works as well, based on the same mechanisme.

    Thanks!

    Tineke  

  • Hi Gertjan,

    My previous answer was incorrect, so I deleted it,

    A->exists(A.nr=B.nr) and B->exists(A.nr=B.nr) does the trick together with the Corticon inference mechanism.

    Thanks,

    Tineke