Handbook
Glossary
rotate! ( seq n -- )
Vocabulary
sequences
.
extras
Inputs
seq
a
sequence
n
an
integer
Outputs
None
Word description
A version of
rotate
that modifies
seq
in place.
Definition
USING:
kernel
math
sequences
sequences.private
;
IN:
sequences.extras
::
rotate!
( seq n -- )
seq
length
:>
len n len
mod
dup
0
<
[
len
+
]
when
seq
bounds-check
drop
0
over
[
2dup
=
]
[
[
seq
exchange-unsafe
]
[
[
1
+
]
bi@
]
2bi
dup
len
=
[
drop
over
]
when
2over
=
[
-rot
nip
over
]
when
]
until
3drop
;