How to compare collections?

Posted by tinvis on 09-Nov-2017 02:13

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.

Posted by tinvis on 13-Nov-2017 03:59

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

Posted by Gertjan Hendriks on 09-Nov-2017 02:28

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

Posted by tinvis on 09-Nov-2017 02:50

Hi Gertjan, yes

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

The entities in the collections are the same.

Tineke  

Posted by Gertjan Hendriks on 09-Nov-2017 02:59

Does this do the trick for you?

A.Nr = B.Nr

A <> B

Posted by tinvis on 09-Nov-2017 04:55

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  

Posted by tinvis on 13-Nov-2017 03:59

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

This thread is closed