17.1. The Sequences Dictionary
Prev | Chapter 17. Sequences | Next

## 17.1. The Sequences Dictionary [sec_the_seque_s_dictionary]

### 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 `NREVERSE`. The 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 `NRECONC`. The 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 standard] 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 standard] 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.45 | Last modified: 2008-04-15

Enter your search termsSubmit search form
Webclisp.cons.orgclisp.podval.orgwww.lisp.org

Prev | Up | Next
Chapter 17. Sequences | Home | Chapter 18. Hash Tables