Next: , Previous: , Up: Sorting and Searching   [Contents][Index]


7.2.3 Chapter Ordering

(require 'chapter-order)

The ‘chap:’ functions deal with strings which are ordered like chapter numbers (or letters) in a book. Each section of the string consists of consecutive numeric or consecutive aphabetic characters of like case.

Function: chap:string<? string1 string2

Returns #t if the first non-matching run of alphabetic upper-case or the first non-matching run of alphabetic lower-case or the first non-matching run of numeric characters of string1 is string<? than the corresponding non-matching run of characters of string2.

(chap:string<? "a.9" "a.10")                    ⇒ #t
(chap:string<? "4c" "4aa")                      ⇒ #t
(chap:string<? "Revised^{3.99}" "Revised^{4}")  ⇒ #t
Function: chap:string>? string1 string2
Function: chap:string<=? string1 string2
Function: chap:string>=? string1 string2

Implement the corresponding chapter-order predicates.

Function: chap:next-string string

Returns the next string in the chapter order. If string has no alphabetic or numeric characters, (string-append string "0") is returnd. The argument to chap:next-string will always be chap:string<? than the result.

(chap:next-string "a.9")                ⇒ "a.10"
(chap:next-string "4c")                 ⇒ "4d"
(chap:next-string "4z")                 ⇒ "4aa"
(chap:next-string "Revised^{4}")        ⇒ "Revised^{5}"