17.1. The Sequences Dictionary [CLHS-17.3]

17.1.1. Additional Macros
17.1.1.1. Macro EXT:DOSEQ
17.1.2. Functions NREVERSE & NRECONC
17.1.3. Functions REMOVE & DELETE
17.1.4. Functions SORT & STABLE-SORT

17.1.1. Additional Macros

17.1.1.1. Macro EXT:DOSEQ

For iteration through a sequence, a macro EXT:DOSEQ, similar to DOLIST, may be used instead of MAP:

(EXT:DOSEQ (variable seqform [resultform])
  {declaration}*
  {tag|form}*)

EXT:DOSEQ forms are iteration forms.

17.1.2. Functions NREVERSE & NRECONC

Function NREVERSEThe result of NREVERSE is always EQ to the argument. NREVERSE on a VECTOR swaps pairs of elements. NREVERSE on a LIST swaps the first and the last element and reverses the list chaining between them.

Function NRECONCThe result of NRECONC is EQ to the first argument unless it is NIL, in which case the result is EQ to the second argument.

17.1.3. Functions REMOVE & DELETE

REMOVE, REMOVE-IF, REMOVE-IF-NOT, REMOVE-DUPLICATES return their argument unchanged, if no element has to be removed.

DELETE, DELETE-IF, DELETE-IF-NOT, DELETE-DUPLICATES destructively modify their argument: If the argument is a LIST, the CDR parts are modified. If the argument is a VECTOR with fill pointer, the fill pointer is lowered and the remaining elements are compacted below the new fill pointer.

Variable CUSTOM:*SEQUENCE-COUNT-ANSI*Contrary to the [ANSI CL] issue RANGE-OF-COUNT-KEYWORD:NIL-OR-INTEGER, negative :COUNT keyword arguments are not allowed unless you set CUSTOM:*SEQUENCE-COUNT-ANSI* to a non-NIL value, in which case “using a negative integer value is functionally equivalent to using a value of zero”, as per the [ANSI CL] issue.

17.1.4. Functions SORT & STABLE-SORT

SORT and STABLE-SORT accept two additional keyword arguments :START and :END:

(SORT sequence predicate &KEY :KEY :START :END)
(STABLE-SORT sequence predicate &KEY :KEY :START :END)

SORT and STABLE-SORT are identical. They implement the mergesort algorithm. Worst case complexity: O(n*log(n)) comparisons, where n is the LENGTH of the subsequence bounded by the :START and :END arguments.


These notes document CLISP version 2.41Last modified: 2006-10-13