]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/circular/circular.factor
Delete empty unit tests files, remove 1- and 1+, reorder IN: lines in a lot of places...
[factor.git] / basis / circular / circular.factor
index 9f3a71f2a81b6f747d49f8badad6257ec5664a49..b3be4651cd627799269edbefa72ac168f97718ba 100644 (file)
@@ -27,8 +27,11 @@ M: circular virtual-seq seq>> ;
     #! change start to (start + n) mod length
     circular-wrap (>>start) ;
 
+: rotate-circular ( circular -- )
+    [ 1 ] dip change-circular-start ;
+
 : push-circular ( elt circular -- )
-    [ set-first ] [ 1 swap change-circular-start ] bi ;
+    [ set-first ] [ rotate-circular ] bi ;
 
 : <circular-string> ( n -- circular )
     0 <string> <circular> ;
@@ -40,16 +43,15 @@ TUPLE: growing-circular < circular length ;
 M: growing-circular length length>> ;
 
 <PRIVATE
+
 : full? ( circular -- ? )
     [ length ] [ seq>> length ] bi = ;
 
-: set-peek ( elt seq -- )
-    [ length 1- ] keep set-nth ;
 PRIVATE>
 
 : push-growing-circular ( elt circular -- )
     dup full? [ push-circular ]
-    [ [ 1+ ] change-length set-peek ] if ;
+    [ [ 1 + ] change-length set-last ] if ;
 
 : <growing-circular> ( capacity -- growing-circular )
     { } new-sequence 0 0 growing-circular boa ;