Handbook
Glossary
?set-nth ( elt n seq -- )
Factor handbook
»
The language
»
Collections
»
Sequence operations
»
Sequence protocol
Prev:
set-nth-unsafe ( elt n seq -- )
Next:
set-length ( n seq -- )
Vocabulary
sequences
Inputs
elt
an
object
n
an
integer
seq
a
sequence
Outputs
None
Word description
A forgiving version of
set-nth
. If the index is out of bounds, does nothing.
Definition
USING:
kernel
sequences.private
;
IN:
sequences
:
?set-nth
( elt n seq -- )
2dup
bounds-check?
[
set-nth-unsafe
]
[
3drop
]
if
;
inline