sequences.extras: rename back to rotate!.
parent
e4ddd9f38e
commit
dad9110889
|
@ -40,7 +40,7 @@ SYMBOLS: supported-layouts supported-formats ;
|
|||
: graphviz-output-appears-to-exist? ( base -- ? )
|
||||
"." directory-files [ swap head? ] with count 1 = ;
|
||||
|
||||
: next! ( seq -- elt ) [ first ] [ 1 rotate-headwards! ] bi ;
|
||||
: next! ( seq -- elt ) [ first ] [ 1 rotate! ] bi ;
|
||||
|
||||
:: smoke-test ( graph -- pass? )
|
||||
supported-formats get-global next! :> -T
|
||||
|
|
|
@ -73,10 +73,13 @@ IN: sequences.extras.tests
|
|||
] unit-test
|
||||
|
||||
|
||||
{ "hello" } [ "hello" 0 rotate-headwards ] unit-test
|
||||
{ "llohe" } [ "hello" 2 rotate-headwards ] unit-test
|
||||
{ "hello" } [ "hello" dup 0 rotate-headwards! ] unit-test
|
||||
{ "lohel" } [ "hello" dup 3 rotate-headwards! ] unit-test
|
||||
{ "hello" "hello" } [ "hello" dup 0 rotate ] unit-test
|
||||
{ "hello" "llohe" } [ "hello" dup 2 rotate ] unit-test
|
||||
[ "hello" dup -1 rotate ] must-fail
|
||||
|
||||
{ "hello" } [ "hello" dup 0 rotate! ] unit-test
|
||||
{ "lohel" } [ "hello" dup 3 rotate! ] unit-test
|
||||
[ "hello" dup -1 rotate! ] must-fail
|
||||
|
||||
{ { } } [ { } [ ] map-concat ] unit-test
|
||||
{ V{ 0 0 1 0 1 2 } } [ 4 iota [ iota ] map-concat ] unit-test
|
||||
|
|
|
@ -186,6 +186,7 @@ PRIVATE>
|
|||
unordered-slices-touch? ;
|
||||
|
||||
ERROR: slices-don't-touch slice1 slice2 ;
|
||||
|
||||
: merge-slices ( slice1 slice2 -- slice/* )
|
||||
slice-order-by-from
|
||||
2dup ordered-slices-touch? [
|
||||
|
@ -194,15 +195,10 @@ ERROR: slices-don't-touch slice1 slice2 ;
|
|||
slices-don't-touch
|
||||
] if ;
|
||||
|
||||
: length- ( n sequence -- m ) length swap - ; inline
|
||||
|
||||
: rotate-headwards ( seq n -- seq' )
|
||||
: rotate ( seq n -- seq' )
|
||||
cut prepend ;
|
||||
|
||||
: rotate-tailwards ( seq n -- seq' )
|
||||
over length- cut prepend ;
|
||||
|
||||
:: rotate-headwards! ( seq n -- )
|
||||
:: rotate! ( seq n -- )
|
||||
n seq bounds-check length :> end
|
||||
0 n [ 2dup = ] [
|
||||
[ seq exchange-unsafe ] [ [ 1 + ] bi@ ] 2bi
|
||||
|
@ -211,7 +207,7 @@ ERROR: slices-don't-touch slice1 slice2 ;
|
|||
] until 3drop ;
|
||||
|
||||
: all-rotations ( seq -- seq' )
|
||||
dup length iota [ rotate-headwards ] with map ;
|
||||
dup length iota [ rotate ] with map ;
|
||||
|
||||
<PRIVATE
|
||||
|
||||
|
@ -600,4 +596,4 @@ PRIVATE>
|
|||
start-all* length ; inline
|
||||
|
||||
: map-zip ( quot: ( x -- y ) -- alist )
|
||||
'[ _ keep swap ] map>alist ; inline
|
||||
'[ _ keep swap ] map>alist ; inline
|
||||
|
|
Loading…
Reference in New Issue