math.order: cleanup stack effects.

db4
John Benediktsson 2012-09-14 09:36:09 -07:00
parent 2a1fbb3396
commit 40e7813214
2 changed files with 4 additions and 5 deletions

View File

@ -31,8 +31,7 @@ HELP: +gt+
{ $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+" } } ;

View File

@ -7,7 +7,7 @@ SYMBOL: +lt+
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 ;
@ -19,10 +19,10 @@ GENERIC: <=> ( obj1 obj2 -- <=> )
! 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