Fix bugs reported by Fengjing Xiao
[clqr.git] / clqr-strings.tex
blobec67b2142c0fa166596bfa97339ca9444b4f6240
1 % Copyright (C) 2008, 2010, 2014, 2018 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; with no Invariant Sections, no Front-Cover Texts and
6 % no Back-Cover Texts. For details see file COPYING.
9 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10 \section{Strings}
11 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12 Strings can as well be manipulated by array and sequence functions;
13 see pages \pageref{section:Arrays} and \pageref{section:Sequences}.
15 \begin{LIST}{1cm}
18 \IT{\arrGOO{(\FU*{STRINGP} \VAR{ foo})\\
19 (\FU*{SIMPLE-STRING-P} \VAR{ foo})}{.}}
21 \retval{\T} if \VAR{foo} is of indicated type.
24 \IT{(\xorGOO{\FU*{STRING=}\\\FU*{STRING-EQUAL}}{\}} \VAR{foo}
25 \VAR{bar}
26 \orGOO{\kwd{:start1} \VAR{ start-foo}\DF{\LIT{0}}\\
27 \kwd{:start2} \VAR{ start-bar}\DF{\LIT{0}}\\
28 \kwd{:end1} \VAR{ end-foo}\DF{\NIL}\\
29 \kwd{:end2} \VAR{ end-bar}\DF{\NIL}}{\}})}
31 Return \retval{\T} if subsequences of \VAR{foo} and \VAR{bar} are
32 equal. Obey/ignore, respectively, case.
35 \IT{(\xorGOO{%
36 \FU{STRING}\Goo{\kwd{/= }\XOR\kwd{-NOT-EQUAL}}\\
37 \FU{STRING}\Goo{\kwd{\boldmath$>$ }\XOR\kwd{-GREATERP}}\\
38 \FU{STRING}\Goo{\kwd{\boldmath$>$= }\XOR\kwd{-NOT-LESSP}}\\
39 \FU{STRING}\Goo{\kwd{\boldmath$<$ }\XOR\kwd{-LESSP}}\\
40 \FU{STRING}\Goo{\kwd{\boldmath$<$= }\XOR\kwd{-NOT-GREATERP}}}{\}}
41 \VAR{foo} \VAR{bar}
42 \orGOO{\kwd{:start1} \VAR{ start-foo}\DF{\LIT{0}}\\
43 \kwd{:start2} \VAR{ start-bar}\DF{\LIT{0}}\\
44 \kwd{:end1} \VAR{ end-foo}\DF{\NIL}\\
45 \kwd{:end2} \VAR{ end-bar}\DF{\NIL}}{\}})}
46 {\index{STRING/=}\index{STRING-NOT-EQUAL}%
47 \index{STRING>@STRING$>$}\index{STRING-GREATERP}%
48 \index{STRING>=@STRING$>$=}\index{STRING-NOT-LESSP}%
49 \index{STRING<@STRING$<$}\index{STRING-LESSP}%
50 \index{STRING<=@STRING$<$=}\index{STRING-NOT-GREATERP}%
51 If \VAR{foo} is lexicographically not equal, greater, not less,
52 less, or not greater, respectively, then return \retval{position}
53 of first mismatching character in \VAR{foo}. Otherwise return
54 \retval{\NIL}. Obey/ignore, respectively, case.
57 \IT{(\FU*{MAKE-STRING} \VAR{size} \orGOO{\kwd{:initial-element} \VAR{ char}\\
58 \kwd{:element-type} \VAR{ type}\DF{\kwd{character}}}{\}})}
60 Return \retval{string} of length \VAR{size}.
63 \IT{\arrGOO{%
64 (\FU*{STRING} \VAR{ x})\\
65 (\xorGOO{%
66 \FU*{STRING-CAPITALIZE}\\
67 \FU*{STRING-UPCASE}\\
68 \FU*{STRING-DOWNCASE}}{\}}
69 \VAR{ x }
70 \orGOO{\kwd{:start} \VAR{ start}\DF{\LIT{0}}\\
71 \kwd{:end} \VAR{ end}\DF{\NIL}}{\}})}{.}}
73 Convert \VAR{x} (\kwd{symbol}, \kwd{string}, or \kwd{character})
74 into a \retval{string}, a \retval{string with capitalized words},
75 an \retval{all-uppercase string}, or an \retval{all-lowercase
76 string}, respectively.
79 \IT{(\xorGOO{%
80 \FU*{NSTRING-CAPITALIZE}\\
81 \FU*{NSTRING-UPCASE}\\
82 \FU*{NSTRING-DOWNCASE}}{\}}
83 \VAR{\DES{string}}
84 \orGOO{\kwd{:start} \VAR{ start}\DF{\LIT{0}}\\
85 \kwd{:end} \VAR{ end}\DF{\NIL}}{\}})}
87 Convert \VAR{string} into a \retval{string with capitalized
88 words}, an \retval{all-uppercase string}, or an
89 \retval{all-lowercase string}, respectively.
92 \IT{(\xorGOO{\FU*{STRING-TRIM}\\
93 \FU*{STRING-LEFT-TRIM}\\
94 \FU*{STRING-RIGHT-TRIM}}{\}} \VAR{char-bag} \VAR{string})}
96 Return \retval{\VAR{string}} with all characters in sequence
97 \VAR{char-bag} removed from both ends, from the beginning, or from
98 the end, respectively.
101 \IT{\arrGOO{(\FU*{CHAR} \VAR{ string} \VAR{ i})\\
102 (\FU*{SCHAR} \VAR{ string} \VAR{ i})}{.}}
104 Return zero-indexed \retval{\VAR{i}th character} of string
105 ignoring/obeying, respectively, fill pointer. \kwd{setf}able.
108 \IT{(\FU*{PARSE-INTEGER} \VAR{string}
109 \orGOO{\kwd{:start} \VAR{ start}\DF{\LIT{0}}\\
110 \kwd{:end} \VAR{ end}\DF{\NIL}\\
111 \kwd{:radix} \VAR{ int}\DF{\LIT{10}}\\
112 \kwd{:junk-allowed} \VAR{ bool}\DF{\NIL}}{\}})}
114 Return \retval{integer} parsed from \VAR{string} and
115 \retvalii{index} of parse end.
118 \end{LIST}
120 %%% Local Variables:
121 %%% mode: latex
122 %%% TeX-master: "clqr"
123 %%% End: