Handbook
Glossary
??nth ( n seq -- elt/f ? )
Vocabulary
sequences
.
extras
Inputs
n
an
integer
seq
a
sequence
Outputs
elt/f
an
object
or
f
?
a
boolean
Word description
A forgiving version of
nth
. If the index is out of bounds, or if the sequence is
f
, simply outputs
f
. Also outputs a boolean to distinguish between the sequence containing an
f
or an out of bounds index.
Definition
USING:
kernel
sequences
sequences.private
;
IN:
sequences.extras
:
??nth
( n seq -- elt/f ? )
2dup
bounds-check?
[
nth-unsafe
t
]
[
2drop
f
f
]
if
;
inline