Factor Documentation
|
Home
|
Glossary
|
Search
factorcode.org
last ( seq -- elt )
Factor documentation
>
Factor handbook
>
The language
>
Collections
>
Sequence operations
>
Accessing sequence elements
Prev:
?second ( seq -- elt/f )
Next:
?last ( seq -- elt/f )
Vocabulary
sequences
Inputs and outputs
seq
a
sequence
elt
an
object
Word description
Outputs the last element of a sequence.
Errors
Throws an error if the sequence is empty.
Definition
USING:
kernel
math
;
IN:
sequences
:
last
( seq -- elt )
[
length
1
-
]
[
nth
]
bi
;