Handbook
Glossary
reverse ( seq -- newseq )
Factor handbook
»
The language
»
Collections
»
Sequence operations
»
Reshaping sequences
Prev:
<repetition> ( len elt -- repetition )
Next:
reversed
Vocabulary
sequences
Inputs
seq
a
sequence
Outputs
newseq
a new sequence
Word description
Outputs a new sequence having the same elements as
seq
but in reverse order.
See also
<reversed>
,
reverse!
Definition
USING:
kernel
sequences.private
;
IN:
sequences
:
reverse
( seq -- newseq )
[
dup
[
length
]
keep
new-sequence
[
0
swap
copy-unsafe
]
keep
reverse!
]
keep
like
;