Paste: hashtables.random

Author: mrjbq7
Mode: factor
Date: Mon, 17 Oct 2011 01:29:53
Plain Text |
USE: hashtables
USE: hashtables.private

M: hashtable random
    [ array>> ] [ assoc-size ] bi
    [ drop f ] [
        random 2 * over [
            tombstone? [ f ] [ 1 - dup 0 < ] if
        ] find drop nip
        [ swap nth ] [ 1 + swap nth ] 2bi 2array
    ] if-zero ;

New Annotation

Summary:
Author:
Mode:
Body: