Handbook
Glossary
?firstn ( n -- quot )
Vocabulary
sequences
.
generalizations
Inputs
n
an
integer
Outputs
None
Word description
A generalization of
?first
that pushes the first
n
elements of a sequence on the stack, or
f
if the sequence is shorter than the requested number of elements.
Examples
Some core words expressed in terms of
?firstn
:
?first
1 ?firstn
Definition
USING:
kernel
sequences.padded
;
IN:
sequences.generalizations
MACRO:
?firstn
( n -- quot )
dup
[
[
f
<padded-tail>
]
curry
]
dip
[
firstn-unsafe
]
curry
compose
;