Accessor elt

Syntax:

elt sequence index object

(setf (elt sequence index) new-object)

Arguments and Values:

sequence—a proper sequence.

index—a valid sequence index for sequence.

object—an object.

new-object—an object.

Description:

14.1.0 3Accesses the element of sequence specified by index.

No longer needed -- implied by "Access". -kmp 13-Jan-92 14.1.0 5 \macref{setf} may be used with \funref{elt} to destructively replace a \term{sequence} element with a new value.

Barmar thinks (and I agree) that this is redundant with the specification of the argument type above. 14.1.0 4 \funref{elt} observes the \term{fill pointer} in those \term{vectors} that have \term{fill pointers}.

Examples:

 (setq str (copy-seq "0123456789")) → "0123456789"
 (elt str 6) → #\6
 (setf (elt str 0) #\#) → #\#
 str → "#123456789"

Side Effects:

None.

Affected By:

None.

Exceptional Situations:

e.g., consider: (LET ((X (NCONC (MAKE-LIST 1000 :INITIAL-ELEMENT 'A) '(B . C)))) (ELT X 1000)) => AShould be prepared to signal an error of type type-error if sequence is not a proper sequence. Should signal an error of type type-error if index is not a valid sequence index for sequence.

See Also:

aref, nth, Section 3.2.1 (Compiler Terminology)

Notes:

aref may be used to access vector elements that are beyond the vector's fill pointer.