diff --git a/core/math/order/order-docs.factor b/core/math/order/order-docs.factor index ef006bbc21..1bdd1009e9 100644 --- a/core/math/order/order-docs.factor +++ b/core/math/order/order-docs.factor @@ -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." diff --git a/core/math/order/order.factor b/core/math/order/order.factor index aae5841185..a06209bf63 100644 --- a/core/math/order/order.factor +++ b/core/math/order/order.factor @@ -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 -- ? )