(access coll key) coll: any type key: any type returns any type
F
M
Retrieves an item from a collection.
- When
coll
is an array or string,key
must be an integer. Positive integers count forwards from the deque's first element, starting from0
, while negative integers count backwards from the deque's last element, starting from-1
. - When
coll
is a table,key
can be any value. Seekeys-eqv?
for a discussion of how table keys are tested for equivalence. - When
coll
is an object or class,key
must be a symbol. Fields, constants and properties are bound both to a fully-qualified name, likeState:x
, and an unqualified name, likex
.
The ?
special syntax can be used to perform fallible indexing: [coll (? key)]
. In
that case, if the index key
is not present, the function succeeds and returns #n
.
When coll
is a deque, slicing syntax is supported: [deq i : j]
, where either i
or
j
may be absent. This returns a newly-allocated, mutable deque which contains all
of the elements from i
inclusive to j
exclusive. Negative indexes are supported.
When key
is an iterator, this function returns a new iterator which produces
[coll item]
for each item produced by key
.
(access coll key)
is usually abbreviated as [coll key]
.