sequences.extras: make rotate support negative n.
parent
dad9110889
commit
4b5b058c20
|
@ -75,7 +75,7 @@ IN: sequences.extras.tests
|
|||
|
||||
{ "hello" "hello" } [ "hello" dup 0 rotate ] unit-test
|
||||
{ "hello" "llohe" } [ "hello" dup 2 rotate ] unit-test
|
||||
[ "hello" dup -1 rotate ] must-fail
|
||||
{ "hello" "ohell" } [ "hello" dup -1 rotate ] unit-test
|
||||
|
||||
{ "hello" } [ "hello" dup 0 rotate! ] unit-test
|
||||
{ "lohel" } [ "hello" dup 3 rotate! ] unit-test
|
||||
|
|
|
@ -196,7 +196,7 @@ ERROR: slices-don't-touch slice1 slice2 ;
|
|||
] if ;
|
||||
|
||||
: rotate ( seq n -- seq' )
|
||||
cut prepend ;
|
||||
dup 0 > [ cut ] [ abs cut* ] if prepend ;
|
||||
|
||||
:: rotate! ( seq n -- )
|
||||
n seq bounds-check length :> end
|
||||
|
|
Loading…
Reference in New Issue