# (lispref.info)Array Functions

Next: Vectors Prev: Arrays Up: Sequences Arrays Vectors
```
Functions that Operate on Arrays
================================

In this section, we describe the functions that accept both strings
and vectors.

- Function: arrayp OBJECT
This function returns `t' if OBJECT is an array (i.e., either a
vector or a string).

(arrayp [a])
=> t
(arrayp "asdf")
=> t

- Function: aref ARRAY INDEX
This function returns the INDEXth element of ARRAY.  The first
element is at index zero.

(setq primes [2 3 5 7 11 13])
=> [2 3 5 7 11 13]
(aref primes 4)
=> 11
(elt primes 4)
=> 11

(aref "abcdefg" 1)
=> 98           ; `b' is ASCII code 98.

- Function: aset ARRAY INDEX OBJECT
This function sets the INDEXth element of ARRAY to be OBJECT.  It
returns OBJECT.

(setq w [foo bar baz])
=> [foo bar baz]
(aset w 0 'fu)
=> fu
w
=> [fu bar baz]

(setq x "asdfasfd")
=> "asdfasfd"
(aset x 3 ?Z)
=> 90
x
=> "asdZasfd"

If ARRAY is a string and OBJECT is not a character, a
`wrong-type-argument' error results.

- Function: fillarray ARRAY OBJECT
This function fills the array ARRAY with pointers to OBJECT,
replacing any previous values.  It returns ARRAY.

(setq a [a b c d e f g])
=> [a b c d e f g]
(fillarray a 0)
=> [0 0 0 0 0 0 0]
a
=> [0 0 0 0 0 0 0]
(setq s "When in the course")
=> "When in the course"
(fillarray s ?-)
=> "------------------"

If ARRAY is a string and OBJECT is not a character, a
`wrong-type-argument' error results.

The general sequence functions `copy-sequence' and `length' are
often useful for objects known to be arrays.  Note: Sequence
Functions.

```

automatically generated by info2www