1 % Copyright (C) 2008, 2009, 2010, 2011 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 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
15 \subsection{Predicates
}
16 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
19 \IT{\arrGOO{(
\FU*
{CONSP
} \VAR{ foo
})\\
20 (
\FU*
{LISTP
} \VAR{ foo
})
}{.
}}
22 Return
\retval{\T} if
\VAR{foo
} is of indicated type.
25 \IT{\arrGOO{(
\FU*
{ENDP
} \VAR{ list
})\\
26 (
\FU*
{NULL
} \VAR{ foo
})
}{.
}\qquad\qquad}
28 Return
\retval{\T} if
\VAR{list
}/
\VAR{foo
} is
\NIL.
31 \IT{(
\FU*
{ATOM
} \VAR{foo
})
\qquad\qquad}
32 {Return
\retval{\T} if
\VAR{foo
} is not a
36 \IT{(
\FU*
{TAILP
} \VAR{foo
} \VAR{list
})
}
38 Return
\retval{\T} if
\VAR{foo
} is a tail of
\VAR{list
}.
41 \IT{(
\FU*
{MEMBER
} \VAR{foo
} \VAR{list
}
43 \kwd{:test
} \VAR{ function
}\DF{\kwd{\#'eql
}}\\
44 \kwd{:test-not
} \VAR{ function
}}{.
}\\
45 \kwd{:key
} \VAR{ function
}}{\
}})
}
47 Return
\retval{tail of
\VAR{list
}} starting with
48 its first element matching
\VAR{foo
}. Return
\retval{\NIL} if
49 there is no such element.
52 \IT{(
\xorGOO{\FU*
{MEMBER-IF
}\\
53 \FU*
{MEMBER-IF-NOT
}}{\
}}
55 \Op{\kwd{:key
} \VAR{function
}})
}
57 Return
\retval{tail of
\VAR{list
}} starting with
58 its first element satisfying
\VAR{test
}. Return
\retval{\NIL} if
59 there is no such element.
62 \IT{(
\FU*
{SUBSETP
} \VAR{list-a
} \VAR{list-b
}
64 \kwd{:test
} \VAR{ function
}\DF{\kwd{\#'eql
}}\\
65 \kwd{:test-not
} \VAR{ function
}}{.
}\\
66 \kwd{:key
} \VAR{ function
}}{\
}})
}
68 Return
\retval{\T} if
\VAR{list-a
} is a subset of
75 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
77 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
80 \IT{(
\FU*
{CONS
} \VAR{foo
} \VAR{bar
})
}
82 Return new cons
\retval{(
\VAR{foo
} \kwd {.
} \VAR{bar
})
}.
85 \IT{(
\FU*
{LIST
} \OPn{\VAR{foo
}})
}
86 {Return
\retval{list of
\VAR{foo
}s
}.
89 \IT{(
\FU*
{LIST
\A} \RP{\VAR{foo
}})
}
90 {Return
\retval{list of
\VAR{foo
}s
}
91 with last
\VAR{foo
} becoming cdr of last cons. Return
92 \retval{\VAR{foo
}} if only one
\VAR{foo
} given.
95 \IT{(
\FU*
{MAKE-LIST
} \VAR{num
} \Op{\kwd{:initial-element
}
98 New
\retval{list
} with
\VAR{num
} elements set to
\VAR{foo
}.
101 \IT{(
\FU*
{LIST-LENGTH
} \VAR{list
})
}
102 {\retval{Length
} of
\VAR{list
};
103 \retval{\NIL} for circular
\VAR{list
}.
106 \IT{(
\FU*
{CAR
} \VAR{list
})
\qquad\qquad}
108 \retval{Car of
\VAR{list
}} or
\retval{\NIL} if
\VAR{list
} is
109 \NIL.
\kwd{SETF
}able.
112 \IT{\arrGOO{(
\FU*
{CDR
} \VAR{ list
})
\qquad\\
113 (
\FU*
{REST
} \VAR{ list
})
}{.
}}
115 \retval{Cdr of
\VAR{list
}} or
\retval{\NIL} if
\VAR{list
}
116 is
\NIL.
\kwd{SETF
}able.
119 \IT{(
\FU*
{NTHCDR
} \VAR{n list
})
}
120 {Return
\retval{tail of
\VAR{list
}} after calling
\FU{cdr
} \VAR{n
} times.
123 \IT{(
\Goo{\FU*
{FIRST
}\XOR\FU*
{SECOND
}\XOR\FU*
{THIRD
}\XOR\FU*
{FOURTH
}\XOR\FU*
{FIFTH
}\XOR\FU*
{SIXTH
}\XOR\dots\XOR\FU*
{NINTH
}\XOR\FU*
{TENTH
}}
128 Return
\retval{nth element of
\VAR{list
}} if any,
129 or
\retval{\NIL} otherwise.
\kwd{SETF
}able.
132 \IT{(
\FU*
{NTH
} \VAR{n list
})
}
134 Zero-indexed
\retval{\VAR{n
}th element
} of
\VAR{list
}.
\kwd{setf
}able.
137 \IT{(
\FU{C
}\VAR{X
}\kwd{R
} \VAR{list
})
}
143 With
\VAR{X
} being one to four
144 \kwd{a
}s and
\kwd{d
}s representing
\FU{CAR
}s and
\FU{CDR
}s, e.g.
145 (
\FU{CADR
} \VAR{bar
}) is equivalent to (
\FU{CAR
} (
\FU{CDR
}
150 \IT{(
\FU*
{LAST
} \VAR{list
} \Op{\VAR{num
}\DF{\LIT{1}}})
}
152 Return list of
\retval{last
\VAR{num
}
153 conses
} of
\VAR{list
}.
156 \IT{(
\xorGOO{\FU*
{BUTLAST
} \VAR{list
}\\
157 \FU*
{NBUTLAST
} \DES{\VAR{list
}}}{\
}}
158 \Op{\VAR{num
}\DF{\LIT{1}}})
}
160 \retval{\VAR{list
}} excluding last
\VAR{num
}
164 \IT{(
\xorGOO{\FU*
{RPLACA
}\\
165 \FU*
{RPLACD
}}{\
}} \DES{\VAR{cons
}} \VAR{object
})
}
167 Replace car, or cdr, respectively, of
\retval{\VAR{cons
}} with
\VAR{object
}.
170 \IT{(
\FU*
{LDIFF
} \VAR{list
} \VAR{foo
})
}
172 If
\VAR{foo
} is a tail of
\VAR{list
}, return
\retval{preceding
173 part of
\VAR{list
}}. Otherwise return
\retval{\VAR{list
}}.
176 \IT{(
\FU*
{ADJOIN
} \VAR{foo
} \VAR{list
}
178 \kwd{:test
} \VAR{ function
}\DF{\kwd{\#'eql
}}\\
179 \kwd{:test-not
} \VAR{ function
}}{.
}\\
180 \kwd{:key
} \VAR{ function
}}{\
}})
}
181 {Return
\retval{\VAR{list
}} if
\VAR{foo
} is
182 already member of
\VAR{list
}. If not, return
\retval{(
\FU{CONS
}
183 \VAR{foo
} \VAR{list
})
}.
186 \IT{(
\MC*
{POP
} \DES{\VAR{place
}})
}
188 Set
\VAR{place
} to (
\FU{CDR
} \VAR{place
}), return
189 \retval{(
\FU{CAR
} \VAR{place
})
}.
192 \IT{(
\MC*
{PUSH
} \VAR{foo
} \DES{\VAR{place
}})
}
194 Set
\VAR{place
} to
\retval{(
\FU{cons
} \VAR{foo
} \VAR{place
})
}.
197 \IT{(
\MC*
{PUSHNEW
} \VAR{foo
} \DES{\VAR{place
}}
199 \kwd{:test
} \VAR{ function
}\DF{\kwd{\#'eql
}}\\
200 \kwd{:test-not
} \VAR{ function
}}{.
}\\
201 \kwd{:key
} \VAR{ function
}}{\
}})
}
203 Set
\VAR{place
} to
\retval{(
\FU{adjoin
} \VAR{foo
} \VAR{place
})
}.
206 \IT{\arrGOO{(
\FU*
{APPEND
} \Op{\OPn{\VAR{proper-list
}}
207 \VAR{ foo
}\DF{\NIL}})\\
208 (
\FU*
{NCONC
} \Op{\OPn{\DES{\VAR{non-circular-list
}}}
209 \VAR{ foo
}\DF{\NIL}})
}{.
}}
211 Return
\retval{concatenated list
} or, with only one argument,
212 \retval{\VAR{foo
}}.
\VAR{foo
} can be of any type.
215 \IT{\arrGOO{(
\FU*
{REVAPPEND
} \VAR{ list
} \VAR{ foo
})\\
217 \DES{\VAR{list
}} \VAR{ foo
})
}{.
}}
219 Return
\retval{concatenated list
} after reversing order in
223 \IT{(
\xorGOO{\FU*
{MAPCAR
}\\
224 \FU*
{MAPLIST
}}{\
}} \VAR{function
} \RP{\VAR{list
}})
}
226 Return
\retval{list of return values
} of
\VAR{function
}
227 successively invoked with corresponding arguments, either cars or
228 cdrs, respectively, from each
\VAR{list
}.
231 \IT{(
\xorGOO{\FU*
{MAPCAN
}\\
232 \FU*
{MAPCON
}}{\
}} \VAR{function
} \RP{\VAR{list
}})
}
234 Return list of
\retval{concatenated return values
} of
235 \VAR{function
} successively invoked with corresponding arguments,
236 either cars or cdrs, respectively, from each
237 \VAR{list
}.
\VAR{function
} should return a list.
240 \IT{(
\xorGOO{\FU*
{MAPC
}\\
241 \FU*
{MAPL
}}{\
}} \VAR{function
} \RP{\VAR{list
}})
}
243 Return
\retval{first
\VAR{list
}} after successively applying
244 \VAR{function
} to corresponding arguments, either cars or cdrs,
245 respectively, from each
\VAR{list
}.
\VAR{function
} should have
249 \IT{(
\FU*
{COPY-LIST
} \VAR{list
})
}
251 Return
\retval{copy
} of
\VAR{list
} with shared elements.
257 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
258 \subsection{Association Lists
}
259 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
260 \label{section:Association Lists
}
263 \IT{(
\FU*
{PAIRLIS
} \VAR{keys
} \VAR{values
} \Op{\VAR{alist
}\DF{\NIL}})
}
265 Prepend to
\retval{\VAR{alist
}} an association list made from
266 lists
\VAR{keys
} and
\VAR{values
}.
269 \IT{(
\FU*
{ACONS
} \VAR{key
} \VAR{value
} \VAR{alist
})
}
271 Return
\retval{\VAR{alist
}} with a (
\VAR{key
} \kwd{.
} \VAR{value
})
275 \IT{\arrGOO{(
\xorGOO{\FU*
{ASSOC
}\\
277 \VAR{ foo
} \VAR{ alist
}
279 \kwd{:test
} \VAR{ test
}\DF{\kwd{\#'eql
}}\\
280 \kwd{:test-not
} \VAR{ test
}}{.
}\\
281 \kwd{:key
} \VAR{ function
}
283 (
\xorGOO{\FU*
{ASSOC-IF
}\Op{\kwd{-NOT
}}\\
284 \FU*
{RASSOC-IF
}\Op{\kwd{-NOT
}}}{\
}} \VAR{ test
} \VAR{ alist
}
285 \Op{\kwd{:key
} \VAR{ function
}})
}{.
}}
286 {\index{ASSOC-IF-NOT
}\index{RASSOC-IF-NOT
}%
287 First
\retval{cons
} whose car, or cdr, respectively, satisfies
291 \IT{(
\FU*
{COPY-ALIST
} \VAR{alist
})
}
293 Return
\retval{copy
} of
\VAR{alist
}.
299 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
301 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
304 \IT{(
\FU*
{TREE-EQUAL
} \VAR{foo
} \VAR{bar
}
305 \xorGOO{\kwd{:test
} \VAR{ test
}\DF{\kwd{\#'eql
}}\\
306 \kwd{:test-not
} \VAR{ test
}}{\
}})
}
308 Return
\retval{\T} if trees
\VAR{foo
} and
\VAR{bar
} have same
309 shape and leaves satisfying
\VAR{test
}.
312 \IT{(
\xorGOO{\FU*
{SUBST
} \VAR{ new
} \VAR{ old
} \VAR{tree
}\\
313 \FU*
{NSUBST
} \VAR{ new
} \VAR{ old
} \DES{\VAR{tree
}}}{\
}}
315 \kwd{:test
} \VAR{ function
}\DF{\kwd{\#'eql
}}\\
316 \kwd{:test-not
} \VAR{ function
}}{.
}\\
317 \kwd{:key
} \VAR{ function
}%
320 Make
\retval{copy of
\VAR{tree
}} with each subtree or leaf
321 matching
\VAR{old
} replaced by
\VAR{new
}.
324 \IT{(
\xorGOO{\FU{SUBST-IF
\Op{-NOT
}} \VAR{ new
} \VAR{ test
} \VAR{tree
}\\
325 \FU{NSUBST-IF
\Op{-NOT
}} \VAR{ new
} \VAR{ test
} \DES{\VAR{tree
}}}{\
}}
326 \Op{\kwd{:key
} \VAR{function
}})
}
329 \index{SUBST-IF-NOT
}%
331 \index{NSUBST-IF-NOT
}%
332 Make
\retval{copy of
\VAR{tree
}} with each subtree or leaf
333 satisfying
\VAR{test
} replaced by
\VAR{new
}.
336 \IT{(
\xorGOO{\FU*
{SUBLIS
} \VAR{ association-list
} \VAR{tree
} \\
337 \FU*
{NSUBLIS
} \VAR{ association-list
} \DES{\VAR{tree
}} }{\
}}
339 \kwd{:test
} \VAR{ function
}\DF{\kwd{\#'eql
}}\\
340 \kwd{:test-not
} \VAR{ function
}}{.
}\\
341 \kwd{:key
} \VAR{ function
}%
344 Make
\retval{copy of
\VAR{tree
}} with each subtree or leaf matching
345 a key in
\VAR{association-list
} replaced by that key's value.
348 \IT{(
\FU*
{COPY-TREE
} \VAR{tree
})
}
350 \retval{Copy of
\VAR{tree
}} with same shape and leaves.
356 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
358 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
364 \FU*
{SET-DIFFERENCE
}\\
366 \FU*
{SET-EXCLUSIVE-OR
}%
367 }{\
}} \VAR{ a
} \VAR{ b
}\\
369 \FU*
{NINTERSECTION
}\\
370 \FU*
{NSET-DIFFERENCE
}%
371 }{\
}} \text{ }\DES{\VAR{a
}}\text{ } \VAR{b
}\\
374 \FU*
{NSET-EXCLUSIVE-OR
}%
375 }{\
}} \text{ }\DES{\VAR{a
}}\text{ } \DES{\VAR{b
}}\text{ }
378 \kwd{:test
} \VAR{ function
}\DF{\kwd{\#'eql
}}\\
379 \kwd{:test-not
} \VAR{ function
}}{.
}\\
380 \kwd{:key
} \VAR{ function
}}{\
}})
}
382 Return
\retval{$a
\cap b$
},
\retval{$a
\setminus b$
},
\retval{$a
\cup b$
}, or
383 \retval{$a\,
\triangle\, b$
}, respectively, of lists
\VAR{a
} and
\VAR{b
}.
391 %%% TeX-master: "clqr"