1 ! Copyright (C) 2012 John Benediktsson
2 ! See http://factorcode.org/license.txt for BSD license
3 USING: accessors kernel math sequences ;
8 { n integer read-only } ;
12 M: rotated length seq>> length ;
15 [ n>> + ] [ seq>> ] bi [
16 length over 0 < [ + ] [
17 2dup >= [ - ] [ drop ] if
21 M: rotated virtual-exemplar seq>> ;
23 INSTANCE: rotated virtual-sequence
25 : all-rotations ( seq -- seq' )
26 dup length iota [ <rotated> ] with map ;