1 USING: help.markup help.syntax kernel math quotations
6 { $values { "obj1" object } { "obj2" object } { "<=>" "an ordering specifier" } }
8 "Compares two objects using an intrinsic linear order, for example, the natural order for real numbers and lexicographic order for strings."
10 "The output value is one of the following:"
12 { { $link +lt+ } " - indicating that " { $snippet "obj1" } " precedes " { $snippet "obj2" } }
13 { { $link +eq+ } " - indicating that " { $snippet "obj1" } " is equal to " { $snippet "obj2" } }
14 { { $link +gt+ } " - indicating that " { $snippet "obj1" } " follows " { $snippet "obj2" } }
19 { $description "Output by " { $link <=> } " when the first object is strictly less than the second object." } ;
22 { $description "Output by " { $link <=> } " when the first object is equal to the second object." } ;
25 { $description "Output by " { $link <=> } " when the first object is strictly greater than the second object." } ;
27 HELP: invert-comparison
28 { $values { "<=>" symbol }
30 { $description "Invert the comparison symbol returned by " { $link <=> } "." }
32 { $example "USING: math.order prettyprint ;" "+lt+ invert-comparison ." "+gt+" } } ;
35 { $values { "obj1" object } { "obj2" object } { "quot" { $quotation "( obj -- newobj )" } } { "<=>" "an ordering specifier" } }
36 { $description "Compares the results of applying the quotation to both objects via " { $link <=> } "." }
37 { $examples { $example "USING: kernel math.order prettyprint sequences ;" "\"hello\" \"hi\" [ length ] compare ." "+gt+" }
41 { $values { "x" real } { "y" real } { "z" real } }
42 { $description "Outputs the greatest of two real numbers." } ;
45 { $values { "x" real } { "y" real } { "z" real } }
46 { $description "Outputs the smallest of two real numbers." } ;
49 { $values { "x" real } { "y" real } { "z" real } { "?" "a boolean" } }
50 { $description "Tests if " { $snippet "x" } " is in the interval " { $snippet "[y,z]" } "." }
51 { $notes "As per the closed interval notation, the end-points are included in the interval." } ;
54 { $values { "obj1" "an object" } { "obj2" "an object" } { "?" "a boolean" } }
55 { $description "Tests if " { $snippet "obj1" } " comes before " { $snippet "obj2" } " using an intrinsic total order." }
56 { $notes "Implemented using " { $link <=> } "." } ;
59 { $values { "obj1" "an object" } { "obj2" "an object" } { "?" "a boolean" } }
60 { $description "Tests if " { $snippet "obj1" } " comes after " { $snippet "obj2" } " using an intrinsic total order." }
61 { $notes "Implemented using " { $link <=> } "." } ;
64 { $values { "obj1" "an object" } { "obj2" "an object" } { "?" "a boolean" } }
65 { $description "Tests if " { $snippet "obj1" } " comes before or equals " { $snippet "obj2" } " using an intrinsic total order." }
66 { $notes "Implemented using " { $link <=> } "." } ;
69 { $values { "obj1" "an object" } { "obj2" "an object" } { "?" "a boolean" } }
70 { $description "Tests if " { $snippet "obj1" } " comes after or equals " { $snippet "obj2" } " using an intrinsic total order." }
71 { $notes "Implemented using " { $link <=> } "." } ;
73 { before? after? before=? after=? } related-words
76 { $values { "x" real } { "y" real } { "z" real } }
77 { $description "Subtracts " { $snippet "y" } " from " { $snippet "x" } ". If the result is less than zero, outputs zero." } ;
79 ARTICLE: "order-specifiers" "Ordering specifiers"
80 "Ordering words such as " { $link <=> } " output one of the following values, indicating that of two objects being compared, the first is less than the second, the two are equal, or that the first is greater than the second:"
83 { $subsection +gt+ } ;
85 ARTICLE: "math.order" "Linear order protocol"
86 "Some classes have an intrinsic order amongst instances:"
88 { $subsection compare }
89 { $subsection invert-comparison }
90 "The above words output order specifiers."
91 { $subsection "order-specifiers" }
92 "Utilities for comparing objects:"
93 { $subsection after? }
94 { $subsection before? }
95 { $subsection after=? }
96 { $subsection before=? }
97 { $see-also "sequences-sorting" } ;