USING: math.ranges kernel random ; : switch ( to from seq -- ) 3dup swap [ nth ] dip [ [ move ] keep ] 2dip rot set-nth ; : randomize ( seq -- seq' ) dup length 1- [ dup 1 > ] [ [ [0,b) random ] keep dup [ rot [ switch ] keep ] dip 1- ] [ drop ] while ;