As an easy first step to supplying Qi with a standard library, I've codified most of the string and character handling in CL. The comments below are taken directly from Common Lisp: the Language and explain each function. The presentation has been rationalised in some cases to accomodate Qi type conventions. The entries are not in alphabetical order (yet) reflecting the order they appear in CLTL. string-equal? : string --> string --> boolean string-equal compares two strings for identity except that differences in case are ignored string<? : string --> string --> boolean string>? : string --> string --> boolean These functions compare the two string arguments lexicographically, and the result is false unless string1 is respectively less than and greater than string2. string-less? : string --> string --> boolean string-greater? : string --> string --> boolean These are exactly like string< and string> respectively, except that distinctions between uppercase and lowercase letters are ignored. string-trim : [character] -->
string --> string
string-trim returns a substring of string, with all characters in [character] stripped off the beginning and end. The function string-left-trim is similar but strips characters off only the beginning; string-right-trim strips off only the end. string-upcase : string -->
string string-upcase returns a string just like string with all lowercase characters replaced by the corresponding uppercase characters. string-downcase is similar, except that uppercase characters are converted to lowercase characters (using char-downcase). string-capitalize produces a copy of string such that, for every word in the copy, the first character of the word, if case-modifiable, is uppercase and any other case-modifiable characters in the word are lowercase. Characters graphic-char? : character --> boolean The argument must be a character object. Returns true if the argument is a ``graphic'' (printing) character, and false if it is a ``non-graphic'' (formatting or control) character. Graphic characters have a standard textual representation as a single glyph, such as A or * or =. By convention, the space character is considered to be graphic. Of the standard characters all but #\Newline are graphic. The semi-standard characters #\Backspace, #\Tab, #\Rubout, #\Linefeed, #\Return, and #\Page are not graphic. alpha-char? : character --> boolean returns true if the argument is an alphabetic character, and otherwise is false. digit-char? : character --> boolean returns true if the argument is an digit character, and otherwise is false. upper-case? : character --> boolean upper-case? is true if the argument is an uppercase character, and otherwise is false. lower-case? is true if the argument is a lowercase character, and otherwise is false. both-case? is true if the argument is an uppercase character and there is a corresponding lowercase character or if the argument is a lowercase character and there is a corresponding uppercase character. Mark Copyright (c) 2008, Mark
Tarver |
||