argmax

It groups the facts of an atom according to certain positions and, for each group, it returns only the facts that maximise a specific position.

The syntax is the following:

@post("atomName", "argmax(p, <p1,..., pn>)").

where atomName is the atom at hand, p is the position to maximise (from 1) and p1, …​, pn are integers denoting the positions that individuate a specific group.

Example 43

f(1,3,"a", 3).
f(4,3,"a", 5).
f(2,6,"b", 7).
f(2,6,"b", 8).
f(3,6,"b", 9).
@output("g").
@post("g","argmax(4,<2,3>)").
@post("g","orderby(1)").

g(X,Y,Z,K) :- f(X,Y,Z,K).

The expected result is: ` g(3,6,"b",9). g(4,3,"a",5).`