delete-random ( seq -- elt ) - Factor Documentation

delete-random ( seq -- elt )
Generating random integers



Vocabulary
random

Inputs
seq a sequence


Outputs
elt an object


Word description
Deletes a random number from a sequence using remove-nth! and returns the deleted object.

Definition
USING: kernel sequences ;

IN: random

: delete-random ( seq -- elt )
[ length random ] keep [ nth ] 2keep remove-nth! drop ;

AltStyle によって変換されたページ (->オリジナル) /