Handbook
Glossary
set-firstn ( n -- quot )
Generalized sequence words
Prev:
firstn ( n -- quot )
Next:
nappend ( n -- seq )
Vocabulary
sequences
.
generalizations
Inputs
n
an
integer
Outputs
None
Word description
A generalization of
set-first
that sets the first
n
elements of a sequence from the top
n
elements of the stack.
Definition
USING:
kernel
math
sequences
;
IN:
sequences.generalizations
MACRO:
set-firstn
( n -- quot )
[
[
drop
]
]
[
[
1
-
]
keep
[
[
swap
bounds-check
nip
]
curry
]
dip
[
set-firstn-unsafe
]
curry
compose
]
if-zero
;