]> gitweb.factorcode.org Git - factor.git/commitdiff
sequences.extras: adding "all-rotations".
authorJohn Benediktsson <mrjbq7@gmail.com>
Sun, 9 Sep 2012 17:37:24 +0000 (10:37 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Sun, 9 Sep 2012 17:37:24 +0000 (10:37 -0700)
extra/sequences/extras/extras.factor

index 25beea2ccef77946f911242ed911b766ea23e2da..13d5634aa2eb27e8922e11cfb0e545916cb9b1d2 100644 (file)
@@ -126,6 +126,9 @@ IN: sequences.extras
         2over = [ -rot nip over ] when
     ] until 3drop ;
 
+: all-rotations ( seq -- seq' )
+    dup length iota [ rotate ] with map ;
+
 : appender-for ( quot exemplar -- quot' vec )
     [ length ] keep new-resizable
     [ [ push-all ] curry compose ] keep ; inline