Permalink
Fetching contributors…
Cannot retrieve contributors at this time
320 lines (282 sloc) 10.3 KB
% Copyright (C) 2008, 2009, 2010, 2014 Bert Burgemeister
%
% Permission is granted to copy, distribute and/or modify this
% document under the terms of the GNU Free Documentation License,
% Version 1.2; with no Invariant Sections, no Front-Cover Texts and
% no Back-Cover Texts. For details see file COPYING.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Sequences}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\label{section:Sequences}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection[Seq.~Predicates]{Sequence Predicates}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{LIST}{1cm}
\IT{(\xorGOO{\FU*{EVERY}\\
\FU*{NOTEVERY}}{\}} \VAR{test}
\RP{\VAR{sequence}})}
{
Return \retval{\NIL} or \retval{\T}, respectively, as soon as \VAR{test} on
any set of corresponding elements of \VAR{sequence}s returns \NIL.
}
\IT{(\xorGOO{\FU*{SOME}\\
\FU*{NOTANY}}{\}} \VAR{test}
\RP{\VAR{sequence}})}
{
Return \retval{value of \VAR{test}} or \retval{\NIL}, respectively, as soon
as \VAR{test} on any set of corresponding elements of
\VAR{sequence}s returns non-\NIL.
}
\IT{(\FU*{MISMATCH} \VAR{sequence-a} \VAR{sequence-b}
\orGOO{\kwd{:from-end} \VAR{ bool}\DF{\NIL}\\
\xorGOO{%
\kwd{:test} \VAR{ function}\DF{\kwd{\#'eql}}\\
\kwd{:test-not} \VAR{ function}}{.}\\
\kwd{:start1} \VAR{ start-a}\DF{\LIT{0}}\\
\kwd{:start2} \VAR{ start-b}\DF{\LIT{0}}\\
\kwd{:end1} \VAR{ end-a}\DF{\NIL}\\
\kwd{:end2} \VAR{ end-b}\DF{\NIL}\\
\kwd{:key} \VAR{ function}}{\}})}
{
Return \retval{position in \VAR{sequence-a}} where
\VAR{sequence-a} and \VAR{sequence-b} begin to
mismatch. Return \retval{\NIL} if
they match entirely.
}
\end{LIST}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection[Seq.~Functions]{Sequence Functions}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{LIST}{1cm}
\IT{(\FU*{MAKE-SEQUENCE} \VAR{sequence-type} \VAR{size}
\Op{\kwd{:initial-element} \VAR{foo}})} % default: implementation-dependent
{
Make \retval{sequence} of \VAR{sequence-type} with \VAR{size} elements.
}
\IT{(\FU*{CONCATENATE} \VAR{type} \OPn{\VAR{sequence}})}
{
Return \retval{concatenated sequence} of \VAR{type}.
}
\IT{(\FU*{MERGE} \VAR{type} \DES{\VAR{sequence-a}} \DES{\VAR{sequence-b}}
\VAR{test} \Op{\kwd{:key} \VAR{function}\DF{\NIL}})}
{
Return \retval{interleaved sequence} of \VAR{type}. Merged sequence
will be sorted if both \VAR{sequence-a} and \VAR{sequence-b} are
sorted.
}
\IT{(\FU*{FILL} \DES{\VAR{sequence}} \VAR{foo}
\orGOO{\kwd{:start} \VAR{ start}\DF{\LIT{0}}\\
\kwd{:end} \VAR{ end}\DF{\NIL}}{\}})}
{
Return \retval{\VAR{sequence}} after setting elements between \VAR{start}
and \VAR{end} to \VAR{foo}.
}
\IT{(\FU*{LENGTH} \VAR{sequence})}
{Return \retval{length of
\VAR{sequence}} (being value of fill pointer if applicable).
}
\IT{(\FU*{COUNT} \VAR{foo} \VAR{sequence}
\orGOO{\kwd{:from-end} \VAR{ bool}\DF{\NIL}\\
\xorGOO{%
\kwd{:test} \VAR{ function}\DF{\kwd{\#'eql}}\\
\kwd{:test-not} \VAR{ function}}{.}\\
\kwd{:start} \VAR{ start}\DF{\LIT{0}}\\
\kwd{:end} \VAR{ end}\DF{\NIL}\\
\kwd{:key} \VAR{ function}}{\}})}
{
Return \retval{number of elements} in \VAR{sequence} which match
\VAR{foo}.
}
\IT{(\xorGOO{\FU*{COUNT-IF}\\
\FU*{COUNT-IF-NOT}}{\}} \VAR{test} \VAR{sequence}
\orGOO{\kwd{:from-end} \VAR{ bool}\DF{\NIL}\\
\kwd{:start} \VAR{ start}\DF{\LIT{0}}\\
\kwd{:end} \VAR{ end}\DF{\NIL}\\
\kwd{:key} \VAR{ function}}{\}})}
{
Return \retval{number of elements} in \VAR{sequence} which satisfy
\VAR{test}.
}
\IT{(\FU*{ELT} \VAR{sequence} \VAR{index})}
{Return \retval{element of
\VAR{sequence}} pointed to by zero-indexed
\VAR{index}. \kwd{setf}able.
}
\IT{(\FU*{SUBSEQ} \VAR{sequence} \VAR{start}
\Op{\VAR{end}\DF{\NIL}})}
{
Return \retval{subsequence of \VAR{sequence}} between \VAR{start}
and \VAR{end}. \kwd{setf}able.
}
\IT{(\xorGOO{\FU*{SORT}\\
\FU*{STABLE-SORT}}{\}} \DES{\VAR{sequence}} \VAR{test}
\Op{\kwd{:key} \VAR{function}})}
{
Return \retval{\VAR{sequence} sorted}. Order
of elements considered equal is not guaranteed/retained, respectively.
}
\IT{\arrGOO{(\FU*{REVERSE} \VAR{ sequence})\\
(\FU*{NREVERSE } \DES{\VAR{sequence}})}{.}}
{
Return \retval{\VAR{sequence} in reverse order}.
}
\IT{(\xorGOO{\FU*{FIND}\\
\FU*{POSITION}}{\}} \VAR{foo} \VAR{sequence}
\orGOO{\kwd{:from-end} \VAR{ bool}\DF{\NIL}\\
\xorGOO{%
\kwd{:test} \VAR{ function}\DF{\kwd{\#'eql}}\\
\kwd{:test-not} \VAR{ test}}{.}\\
\kwd{:start} \VAR{ start}\DF{\LIT{0}}\\
\kwd{:end} \VAR{ end}\DF{\NIL}\\
\kwd{:key} \VAR{ function}}{\}})}
{
Return \retval{first element} in \VAR{sequence} which
matches \VAR{foo}, or its \retval{position} relative to the begin
of \VAR{sequence}, respectively.
}
\IT{(\xorGOO{\FU*{FIND-IF}\\
\FU*{FIND-IF-NOT}\\\FU*{POSITION-IF}\\
\FU*{POSITION-IF-NOT}}{\}} \VAR{test} \VAR{sequence}
\orGOO{\kwd{:from-end} \VAR{ bool}\DF{\NIL}\\
\kwd{:start} \VAR{ start}\DF{\LIT{0}}\\
\kwd{:end} \VAR{ end}\DF{\NIL}\\
\kwd{:key} \VAR{ function}}{\}})}
{
Return \retval{first element} in \VAR{sequence} which satisfies \VAR{test}, or
its \retval{position} relative to the begin of \VAR{sequence}, respectively.
}
\IT{(\FU*{SEARCH} \VAR{sequence-a} \VAR{sequence-b}
\orGOO{\kwd{:from-end} \VAR{ bool}\DF{\NIL}\\
\xorGOO{%
\kwd{:test} \VAR{ function}\DF{\kwd{\#'eql}}\\
\kwd{:test-not} \VAR{ function}}{.}\\
\kwd{:start1} \VAR{ start-a}\DF{\LIT{0}}\\
\kwd{:start2} \VAR{ start-b}\DF{\LIT{0}}\\
\kwd{:end1} \VAR{ end-a}\DF{\NIL}\\
\kwd{:end2} \VAR{ end-b}\DF{\NIL}\\
\kwd{:key} \VAR{ function}}{\}})}
{
Search \VAR{sequence-b} for a subsequence matching
\VAR{sequence-a}. Return \retval{position} in \VAR{sequence-b}, or
\retval{\NIL}.
}
\IT{(\xorGOO{\FU*{REMOVE} \VAR{ foo } \VAR{sequence}\\
\FU*{DELETE} \VAR{ foo } \DES{\VAR{sequence}}}{\}}
\orGOO{\kwd{:from-end} \VAR{ bool}\DF{\NIL}\\
\xorGOO{%
\kwd{:test} \VAR{ function}\DF{\kwd{\#'eql}}\\
\kwd{:test-not} \VAR{ function}}{.}\\
\kwd{:start} \VAR{ start}\DF{\LIT{0}}\\
\kwd{:end} \VAR{ end}\DF{\NIL}\\
\kwd{:key} \VAR{ function}\\
\kwd{:count} \VAR{ count}\DF{\NIL}}{\}})}
{
Make \retval{copy of \VAR{sequence}} without elements matching
\VAR{foo}.
}
\IT{(\xorGOO{%
\arrGOO{
\FU*{REMOVE-IF}\\
\FU*{REMOVE-IF-NOT}}{\}} \VAR{ test } \VAR{sequence}\\
\arrGOO{
\FU*{DELETE-IF}\\
\FU*{DELETE-IF-NOT}}{\}} \VAR{ test }
\DES{\VAR{sequence}}\text{ }}{\}}
\orGOO{\kwd{:from-end} \VAR{ bool}\DF{\NIL}\\
\kwd{:start} \VAR{ start}\DF{\LIT{0}}\\
\kwd{:end} \VAR{ end}\DF{\NIL}\\
\kwd{:key} \VAR{ function}\\
\kwd{:count} \VAR{ count}\DF{\NIL}}{\}})}
{
Make \retval{copy of \VAR{sequence}} with all (or \VAR{count}) elements
satisfying \VAR{test} removed.
}
\IT{(\xorGOO{\FU*{REMOVE-DUPLICATES} \VAR{ sequence }\\
\FU*{DELETE-DUPLICATES } \DES{\VAR{sequence}}}{\}}
\orGOO{\kwd{:from-end} \VAR{ bool}\DF{\NIL}\\
\xorGOO{%
\kwd{:test} \VAR{ function}\DF{\kwd{\#'eql}}\\
\kwd{:test-not} \VAR{ function}}{.}\\
\kwd{:start} \VAR{ start}\DF{\LIT{0}}\\
\kwd{:end} \VAR{ end}\DF{\NIL}\\
\kwd{:key} \VAR{ function}}{\}})}
{
Make \retval{copy of \VAR{sequence}} without duplicates.
}
\IT{(\xorGOO{%
\FU*{SUBSTITUTE} \VAR{ new} \VAR{ old } \VAR{sequence} \\
\FU*{NSUBSTITUTE} \VAR{ new} \VAR{ old } \DES{\VAR{sequence}} }{\}}
\orGOO{\kwd{:from-end} \VAR{ bool}\DF{\NIL}\\
\xorGOO{%
\kwd{:test} \VAR{ function}\DF{\kwd{\#'eql}}\\
\kwd{:test-not} \VAR{ function}}{.}\\
\kwd{:start} \VAR{ start}\DF{\LIT{0}}\\
\kwd{:end} \VAR{ end}\DF{\NIL}\\
\kwd{:key} \VAR{ function}\\
\kwd{:count} \VAR{ count}\DF{\NIL}}{\}})}
{
Make \retval{copy of \VAR{sequence}} with all (or \VAR{count})
\VAR{old}s replaced by \VAR{new}.
}
\IT{(\xorGOO{%
\arrGOO{%
\FU*{SUBSTITUTE-IF}\\
\FU*{SUBSTITUTE-IF-NOT}}{\}}
\VAR{ new} \VAR{ test } \VAR{sequence}\\
\arrGOO{%
\FU*{NSUBSTITUTE-IF}\\
\FU*{NSUBSTITUTE-IF-NOT}}{\}}
\VAR{ new} \VAR{ test } \DES{\VAR{sequence}}\text{ }
}{\}}
\orGOO{\kwd{:from-end} \VAR{ bool}\DF{\NIL}\\
\kwd{:start} \VAR{ start}\DF{\LIT{0}}\\
\kwd{:end} \VAR{ end}\DF{\NIL}\\
\kwd{:key} \VAR{ function}\\
\kwd{:count} \VAR{ count}\DF{\NIL}}{\}})}
{
Make \retval{copy of \VAR{sequence}} with all (or \VAR{count})
elements satisfying \VAR{test} replaced by
\VAR{new}.
}
\IT{(\FU*{REPLACE} \DES{\VAR{sequence-a}} \VAR{sequence-b}
\orGOO{\kwd{:start1} \VAR{ start-a}\DF{\LIT{0}}\\
\kwd{:start2} \VAR{ start-b}\DF{\LIT{0}}\\
\kwd{:end1} \VAR{ end-a}\DF{\NIL}\\
\kwd{:end2} \VAR{ end-b}\DF{\NIL}}{\}})}
{
Replace elements of \retval{\VAR{sequence-a}} with elements of
\VAR{sequence-b}.
}
\IT{(\FU*{MAP} \VAR{type} \VAR{function} \RP{\VAR{sequence}})}
{
Apply \VAR{function} successively to corresponding elements of the
\VAR{sequence}s. Return values as a \retval{sequence} of
\VAR{type}. If \VAR{type} is \NIL, return \retval{\NIL}.
}
\IT{(\FU*{MAP-INTO} \DES{\VAR{result-sequence}} \VAR{function}
\OPn{\VAR{sequence}})}
{
Store into \retval{\VAR{result-sequence}} successively values of
\VAR{function} applied to corresponding elements of the \VAR{sequence}s.
}
\IT{(\FU*{REDUCE} \VAR{function} \VAR{sequence}
\orGOO{\kwd{:initial-value} \VAR{ foo}\DF{\NIL}\\
\kwd{:from-end} \VAR{ bool}\DF{\NIL}\\
\kwd{:start} \VAR{ start}\DF{\LIT{0}}\\
\kwd{:end} \VAR{ end}\DF{\NIL}\\
\kwd{:key} \VAR{ function}}{\}})}
{
Starting with the first two elements of \VAR{sequence}, apply
\VAR{function} successively to its last return value together with the next
element of \VAR{sequence}. Return \retval{last value} of {function}.
}
\IT{(\FU*{COPY-SEQ} \VAR{sequence})}
{
\retval{Copy of \VAR{sequence}} with shared elements.
}
\end{LIST}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: "clqr"
%%% End: