random: speedup randomize.

db4
John Benediktsson 2013-02-27 14:51:29 -08:00
parent b47a737321
commit 29b8c4b993
1 changed files with 4 additions and 2 deletions

View File

@ -94,8 +94,10 @@ M: hash-set random table>> random first ;
: randomize-n-last ( seq n -- seq )
[ dup length dup ] dip - 1 max '[ dup _ > ]
[ [ random ] [ 1 - ] bi [ pick exchange-unsafe ] keep ]
while drop ;
random-generator get '[
[ _ (random-integer) ] [ 1 - ] bi
[ pick exchange-unsafe ] keep
] while drop ;
: randomize ( seq -- randomized )
dup length randomize-n-last ;