String comparisons: information density improved.
[clqr.git] / clqr-strings.tex
blobab730ae4e42efd7fc113fa90c80dbf900a47d9f0
1 % Copyright (C) 2008, 2010 Bert Burgemeister
3 % Permission is granted to copy, distribute and/or modify this
4 % document under the terms of the GNU Free Documentation License,
5 % Version 1.2 or any later version published by the Free Software
6 % Foundation; with no Invariant Sections, no Front-Cover Texts and
7 % no Back-Cover Texts. For details see file COPYING.
10 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11 \section{Strings}
12 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13 Strings can as well be manipulated by array and sequence functions;
14 see pages \pageref{section:Arrays} and \pageref{section:Sequences}.
16 \begin{LIST}{1cm}
19 \IT{\arrGOO{(\FU*{STRINGP} \VAR{ foo})\\
20 (\FU*{SIMPLE-STRING-P} \VAR{ foo})}{.}}
22 \retval{\T} if \VAR{foo} is of indicated type.
25 \IT{(\xorGOO{\FU*{STRING=}\\\FU*{STRING-EQUAL}}{\}} \VAR{foo}
26 \VAR{bar}
27 \orGOO{\kwd{:start1} \VAR{ start-foo}\DF{\LIT{0}}\\
28 \kwd{:start2} \VAR{ start-bar}\DF{\LIT{0}}\\
29 \kwd{:end1} \VAR{ end-foo}\DF{\NIL}\\
30 \kwd{:end2} \VAR{ end-bar}\DF{\NIL}}{\}})}
32 Return \retval{\T} if subsequences of \VAR{foo} and \VAR{bar} are
33 equal. Obey/ignore, respectively, case.
36 \IT{(\xorGOO{%
37 \FU{STRING}\Goo{\kwd{/= }\XOR\kwd{-NOT-EQUAL}}\\
38 \FU{STRING}\Goo{\kwd{\boldmath$>$ }\XOR\kwd{-GREATERP}}\\
39 \FU{STRING}\Goo{\kwd{\boldmath$>$= }\XOR\kwd{-NOT-LESSP}}\\
40 \FU{STRING}\Goo{\kwd{\boldmath$<$ }\XOR\kwd{-LESSP}}\\
41 \FU{STRING}\Goo{\kwd{\boldmath$<$= }\XOR\kwd{-NOT-GREATERP}}}{\}}
42 \VAR{foo} \VAR{bar}
43 \orGOO{\kwd{:start1} \VAR{ start-foo}\DF{\LIT{0}}\\
44 \kwd{:start2} \VAR{ start-bar}\DF{\LIT{0}}\\
45 \kwd{:end1} \VAR{ end-foo}\DF{\NIL}\\
46 \kwd{:end2} \VAR{ end-bar}\DF{\NIL}}{\}})}
47 {\index{STRING/=}\index{STRING-NOT-EQUAL}%
48 \index{STRING>@STRING$>$}\index{STRING-GREATERP}%
49 \index{STRING>=@STRING$>$=}\index{STRING-NOT-LESSP}%
50 \index{STRING<@STRING$<$}\index{STRING-LESSP}%
51 \index{STRING<=@STRING$<$=}\index{STRING-NOT-GREATERP}%
52 If \VAR{foo} is lexicographically not equal, greater, not less,
53 less, or not greater, respectively, then return \retval{position}
54 of first mismatching character in \VAR{foo}. Otherwise return
55 \retval{\NIL}. Obey/ignore, respectively, case.
58 \IT{(\FU*{STRING} \VAR{x})}
60 Convert \VAR{x} (\kwd{symbol}, \kwd{string}, or \kwd{character})
61 into a \retval{string}.
64 \IT{(\FU*{MAKE-STRING} \VAR{size} \orGOO{\kwd{:initial-element} \VAR{ char}\\
65 \kwd{:element-type} \VAR{ type}\DF{\kwd{character}}}{\}})}
67 Return \retval{string} of length \VAR{size}.
70 \IT{(\xorGOO{\FU{STRING}\\
71 \FU{NSTRING}}{\}}\kwd{-}\xorGOO{\kwd{CAPITALIZE}\\
72 \kwd{UPCASE}\\
73 \kwd{DOWNCASE}}{\}}
74 \VAR{string}
75 \orGOO{\kwd{:start} \VAR{ start}\DF{\LIT{0}}\\
76 \kwd{:end} \VAR{ end}\DF{\NIL}}{\}})}
77 {\index{STRING-CAPITALIZE}%
78 \index{STRING-UPCASE}%
79 \index{STRING-DOWNCASE}%
80 \index{NSTRING-CAPITALIZE}%
81 \index{NSTRING-UPCASE}%
82 \index{NSTRING-DOWNCASE}%
83 Return \retval{\VAR{string}} (not modified or modified,
84 respectively) with first letter of every word turned into uppercase,
85 letters all uppercase, or letters all lowercase, respectively.
88 \IT{(\xorGOO{\FU*{STRING-TRIM}\\
89 \FU*{STRING-LEFT-TRIM}\\
90 \FU*{STRING-RIGHT-TRIM}}{\}} \VAR{char-bag} \VAR{string})}
92 Return \retval{\VAR{string}} with all characters in sequence
93 \VAR{char-bag} removed from both ends, from the beginning, or from
94 the end, respectively.
97 \IT{\arrGOO{(\FU*{CHAR} \VAR{ string} \VAR{ i})\\
98 (\FU*{SCHAR} \VAR{ string} \VAR{ i})}{.}}
100 Return zero-indexed \retval{\VAR{i}th character} of string
101 ignoring/obeying, respectively, fill pointer. \kwd{setf}able.
104 \IT{(\FU*{PARSE-INTEGER} \VAR{string}
105 \orGOO{\kwd{:start} \VAR{ start}\DF{\LIT{0}}\\
106 \kwd{:end} \VAR{ end}\DF{\NIL}\\
107 \kwd{:radix} \VAR{ int}\DF{\LIT{10}}\\
108 \kwd{:junk-allowed} \VAR{ bool}\DF{\NIL}}{\}})}
110 Return \retval{integer} parsed from \VAR{string} and
111 \retvalii{index} of parse end.
114 \end{LIST}
116 %%% Local Variables:
117 %%% mode: latex
118 %%% TeX-master: "clqr"
119 %%% End: