sequences.extras: make rotate support negative n.

locals-and-roots
John Benediktsson 2016-04-04 11:05:28 -07:00
parent dad9110889
commit 4b5b058c20
2 changed files with 2 additions and 2 deletions

View File

@ -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

View File

@ -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