IN: sequences USING: help kernel words ; HELP: sort { $values { "seq" "a sequence" } { "quot" "a comparator quotation" } { "sortedseq" "a new sorted sequence" } } { $description "Sorts the elements into a new sequence of the same class as " { $snippet "seq" } "." } ; HELP: nsort { $values { "seq" "a mutable sequence" } { "quot" "a comparator quotation" } } { $description "Sorts the sequence in-place." } { $side-effects "seq" } ; HELP: natural-sort { $values { "seq" "a sequence of real numbers" } { "sortedseq" "a new sorted sequence" } } { $description "Sorts a sequence of objects in natural order using the " { $link <=> } " word." } ; HELP: binsearch { $values { "elt" "an object" } { "seq" "a sorted sequence" } { "quot" "a comparator quotation" } { "i" "the index of the search result" } } { $description "Given a sequence that is sorted with respect to the " { $snippet "quot" } " comparator, searches for an element equal to " { $snippet "elt" } ", or failing that, the greatest element smaller than " { $snippet "elt" } ". Comparison is performed with " { $snippet "quot" } "." $terpri "Outputs -1 if the sequence is empty. If the sequence has at least one element, this word always outputs a valid index." } ; HELP: binsearch* { $values { "elt" "an object" } { "seq" "a sorted sequence" } { "quot" "a comparator quotation" } { "result" "the search result" } } { $description "Variant of " { $link binsearch } " which outputs the found element rather than its index in the sequence." $terpri "Outputs " { $link f } " if the sequence is empty. If the sequence has at least one element, this word always outputs a sequence element." } ;