]> gitweb.factorcode.org Git - factor.git/commitdiff
sequences.extras: rename back to rotate!.
authorJohn Benediktsson <mrjbq7@gmail.com>
Mon, 4 Apr 2016 17:59:32 +0000 (10:59 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 4 Apr 2016 17:59:32 +0000 (10:59 -0700)
extra/graphviz/graphviz-tests.factor
extra/sequences/extras/extras-tests.factor
extra/sequences/extras/extras.factor

index 18bb1f045c33627c548f66acb454d910c9f1941c..d00d3ab0d98c46730024ea9e190b0111c40cefd8 100644 (file)
@@ -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
index 8a83650c328a3b98d1c94a19886ea21381d73211..3d7c4ff36cf0f994d3e398c0dae1e178871f3694 100644 (file)
@@ -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
index 04ebf1837400ab0be3c57f1677a7ee25d7b3337a..6aca1b284c9f734d2732e0c87ca0ae1ae5be7863 100644 (file)
@@ -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
\ No newline at end of file
+    '[ _ keep swap ] map>alist ; inline