max
It calculates the maximum value for one ore more positions on an atom, grouping by the other positions.
The syntax is the following:
@post("atomName","max(p1, ..., pn)").
where atomName
is the atom at hand, p1, …, pn
are integers denoting a valid position in atomName (starting from 1).
Example 41
t(1,"b",5).
t(1,"b",1).
t(1,"c",1).
p(X,Y,Z) :- t(X,Y,Z).
@output("p").
@post("p","max(3)").
The expected result is:
p(1,"b",5). p(1,"c",1).
Note that the max value is computed according to the lexicographic order over tuples obtained by projecting on the positions in the post-processing annotation.
Example
t(2,"b",1).
t(1,"c",1).
t(2,"a",1).
q(X,Y,Z) :- t(X,Y,Z).
@output("q").
@post("q","max(2,1)").
Then the expected result is ` p(1,"c",1). ` Indeed, all the three tuples ("b",2)
, ("c",1)
and ("a",2)
fall within one group, and ("c",1)
is a maximal tuple among them according to the lexicographic order.