Linear order protocol - Factor Documentation (original) (raw)
Some classes define an intrinsic order amongst instances. This includes numbers, sequences (in particular, strings), and words. <=> ( obj1 obj2 -- <=> )
>=< ( obj1 obj2 -- >=< )
compare ( obj1 obj2 quot -- <=> )
invert-comparison ( <=> -- >=< )
The above words output order specifiers. Ordering specifiers
Utilities for comparing objects:
before? ( obj1 obj2 -- ? )
after=? ( obj1 obj2 -- ? )
before=? ( obj1 obj2 -- ? )
max ( obj1 obj2 -- obj )
clamp ( x min max -- y )
Out of the above generic words, it suffices to implement <=> alone. The others may be provided as an optimization. Linear order example
See also
Sorting sequences