My goal is to find the maximum value, or more in general an arithmetic expression, for some objects.
Here's an example:
card(one).
card(two).
card(three).
value(one,10).
value(two,20).
value(three,30).
It's obvious that the "winner" is the card 3. But I don't know how to build a predicate that is able to compare each value of an object with the others.
EDIT: I've tried this one
winner(X):- card(X), value(X, ValueX), card(Y), value(Y, ValueY), ValueX < ValueY.
The result is the "winners", but I need the "absolute winner" which is only one. In the example above we have card 2 and card 3, because card 2 win on 1 and 3 win on 2. So we have 2 winners, but the absolute one is only card 3. Is there a way to achieve this?