]> gitweb.factorcode.org Git - factor.git/blob - basis/sorting/human/human-docs.factor
b3657b60a2f8431261040851eb68de49a901a3c9
[factor.git] / basis / sorting / human / human-docs.factor
1 ! Copyright (C) 2009 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: help.markup help.syntax kernel math.order quotations
4 sequences strings ;
5 IN: sorting.human
6
7 HELP: find-numbers
8 { $values
9      { "sequence" sequence }
10      { "sequence'" sequence }
11 }
12 { $description "Splits a string on numbers and returns a sequence of sequences and integers." } ;
13
14 HELP: human<=>
15 { $values
16      { "obj1" object } { "obj2" object }
17      { "<=>" "an ordering specifier" }
18 }
19 { $description "Compares two objects after converting numbers in the string into integers." } ;
20
21 HELP: human>=<
22 { $values
23      { "obj1" object } { "obj2" object }
24      { ">=<" "an ordering specifier" }
25 }
26 { $description "Compares two objects using the " { $link human<=> } " word and inverts the result." } ;
27
28 ARTICLE: "sorting.human" "Human-friendly sorting"
29 "The " { $vocab-link "sorting.human" } " vocabulary sorts by numbers as a human would -- by comparing their magnitudes -- rather than in a lexicographic way. For example, sorting a1, a10, a03, a2 with human sort returns a1, a2, a03, a10, while sorting with natural sort returns a03, a1, a10, a2." $nl
30 "Comparing two objects:"
31 { $subsections
32     human<=>
33     human>=<
34 }
35 "Splitting a string into substrings and integers:"
36 { $subsections find-numbers } ;
37
38 ABOUT: "sorting.human"