The comparison function cmp should take values in {-1,0,1} as follows:
if a>b then cmp(a,b) = 1,
if a<b then cmp(a,b) = -1,
if a,b are incomparable then cmp(a,b) = 0,
cmp(a,a) can be either -1 or 1.
As an example, consider the poset of divisors.
i1 : L = 2..20 o1 = (2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20) o1 : Sequence |
i2 : cmp = (i,j) -> if i%j==0 then 1 else if j%i==0 then -1 else 0; |
i3 : prime = minimalObjects(L, cmp); |
i4 : select(L, i -> prime#i) o4 = (2, 3, 5, 7, 11, 13, 17, 19) o4 : Sequence |