 USING: accessors alien.c-types alien.data arrays assocs
 byte-arrays byte-vectors combinators fry io.backend io.binary
 kernel locals math math.bitwise math.constants math.functions
-math.order math.ranges namespaces sequences sets summary system
-vocabs.loader ;
+math.order math.ranges namespaces sequences sequences.private
+sets summary system vocabs.loader ;
 IN: random
 
 SYMBOL: system-random-generator


M: f random-32* ( obj -- * ) no-random-number-generator ;

: random-bytes ( n -- byte-array )
    random-generator get random-bytes* ;

<PRIVATE

: random-integer ( n -- n' )
    dup log2 7 + 8 /i 1 +
    [ random-bytes be> ]
    [ 3 shift 2^ ] bi / * >integer ;

PRIVATE>


        [ length random-integer ] keep nth
    ] if-empty ;

: randomize-n-last ( seq n -- seq )
    [ dup length dup ] dip - 1 max '[ dup _ > ]
    [ [ random ] [ 1 - ] bi [ pick exchange-unsafe ] keep ]
    while drop ;

: randomize ( seq -- randomized )
