Handbook
Glossary
?last ( seq -- elt/f )
Factor handbook
»
The language
»
Collections
»
Sequence operations
»
Accessing sequence elements
Prev:
last ( seq -- elt )
Next:
first2 ( seq -- first second )
Vocabulary
sequences
Inputs
seq
a
sequence
Outputs
elt/f
an
object
or
f
Word description
A forgiving version of
last
. If the sequence is empty, or if the sequence is
f
, simply outputs
f
.
Definition
USING:
kernel
math
sequences.private
;
IN:
sequences
:
?last
( seq -- elt/f )
index-of-last
over
0
<
[
2drop
f
]
[
nth-unsafe
]
if
;
inline