add >=< word to math.order

db4
Doug Coleman 2009-01-08 16:06:01 -06:00
parent 3026f1c8e3
commit 076b2d0893
2 changed files with 9 additions and 0 deletions

View File

@ -15,6 +15,12 @@ HELP: <=>
}
} ;
HELP: >=<
{ $values { "obj1" object } { "obj2" object } { ">=<" "an ordering specifier" } }
{ $description "Compares two objects using the " { $link <=> } " comparator and inverts the output." } ;
{ <=> >=< } related-words
HELP: +lt+
{ $description "Output by " { $link <=> } " when the first object is strictly less than the second object." } ;
@ -85,6 +91,7 @@ ARTICLE: "order-specifiers" "Ordering specifiers"
ARTICLE: "math.order" "Linear order protocol"
"Some classes have an intrinsic order amongst instances:"
{ $subsection <=> }
{ $subsection >=< }
{ $subsection compare }
{ $subsection invert-comparison }
"The above words output order specifiers."

View File

@ -13,6 +13,8 @@ SYMBOL: +gt+
GENERIC: <=> ( obj1 obj2 -- <=> )
: >=< ( obj1 obj2 -- >=< ) <=> invert-comparison ; inline
M: real <=> 2dup < [ 2drop +lt+ ] [ number= +eq+ +gt+ ? ] if ;
GENERIC: before? ( obj1 obj2 -- ? )