Handbook
Glossary
?nth ( n seq -- elt/f )
Factor handbook
»
The language
»
Collections
»
Sequence operations
»
Accessing sequence elements
Next:
first ( seq -- first )
Vocabulary
sequences
Inputs
n
an
integer
seq
a
sequence
Outputs
elt/f
an
object
or
f
Word description
A forgiving version of
nth
. If the index is out of bounds, or if the sequence is
f
, simply outputs
f
.
See also
nth
Definition
USING:
kernel
sequences.private
;
IN:
sequences
:
?nth
( n seq -- elt/f )
2dup
bounds-check?
[
nth-unsafe
]
[
2drop
f
]
if
;
inline