Paste: randomize
Author: | mrjbq7 |
Mode: | factor |
Date: | Thu, 25 Sep 2008 20:02:33 |
Plain Text |
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 ;
Author: | mrjbq7 |
Mode: | factor |
Date: | Thu, 25 Sep 2008 20:12:55 |
Plain Text |
: randomize ( seq -- seq' )
dup length 1-
[ dup 1 > ] [
[ [0,b) random ] keep dup
[ rot [ exchange ] keep ] dip 1-
] [ drop ] while ;
Author: | erg |
Mode: | factor |
Date: | Thu, 25 Sep 2008 20:19:55 |
Plain Text |
: randomize2 ( seq -- seq' )
dup length 1 swap [a,b) <reversed> [ dup random pick exchange ] each ;
Author: | erg |
Mode: | factor |
Date: | Thu, 25 Sep 2008 20:19:58 |
Plain Text |
: randomize2 ( seq -- seq' )
dup length 1 swap [a,b) <reversed> [ dup random pick exchange ] each ;
Author: | slava |
Mode: | factor |
Date: | Thu, 25 Sep 2008 21:17:03 |
Plain Text |
: radomize3 ( seq -- seq' )
dup length 1 (a,b] [ dup random pick exchange ] each ;
New Annotation