Handbook
Glossary
insert-nth ( elt n seq -- seq' )
Factor handbook
»
The language
»
Collections
»
Sequence operations
»
Adding and removing sequence elements
Prev:
suffix ( seq elt -- newseq )
Next:
remove ( elt seq -- newseq )
Vocabulary
sequences
Inputs
elt
an
object
n
an
integer
seq
a
sequence
Outputs
seq'
a
sequence
Word description
Creates a new sequence where the
n
th index is set to the input object.
Examples
USING: prettyprint sequences ; 40 3 { 10 20 30 50 } insert-nth .
{ 10 20 30 40 50 }
Definition
USING:
kernel
;
IN:
sequences
:
insert-nth
( elt n seq -- seq' )
swap
cut-slice
[
swap
suffix
]
dip
append
;