{ $description "Output by " { $link <=> } " when the first object is strictly greater than the second object." } ;
HELP: invert-comparison
-{ $values { "<=>" symbol }
- { "<=>'" symbol } }
+{ $values { "<=>" symbol } { ">=<" symbol } }
{ $description "Invert the comparison symbol returned by " { $link <=> } "." }
{ $examples
{ $example "USING: math.order prettyprint ;" "+lt+ invert-comparison ." "+gt+" } } ;
SYMBOL: +eq+
SYMBOL: +gt+
-: invert-comparison ( <=> -- <=>' )
+: invert-comparison ( <=> -- >=< )
#! Can't use case, index or nth here
dup +lt+ eq? [ drop +gt+ ] [ +eq+ eq? +eq+ +lt+ ? ] if ;
! Defining a math generic for comparison forces a single math
! promotion, and speeds up comparisons on numbers.
-: (real<=>) ( x y -- ? )
+: (real<=>) ( x y -- <=> )
2dup < [ 2drop +lt+ ] [ number= +eq+ +gt+ ? ] if ; inline
-MATH: real<=> ( x y -- ? )
+MATH: real<=> ( x y -- <=> )
M: fixnum real<=> { fixnum fixnum } declare (real<=>) ; inline
M: bignum real<=> { bignum bignum } declare (real<=>) ; inline
M: float real<=> { float float } declare (real<=>) ; inline