Enum.take_random
You're seeing just the function
take_random
, go back to Enum module for more information.
Specs
take_random(t(), non_neg_integer()) :: list()
Takes count
random elements from enumerable
.
Note that this function will traverse the whole enumerable
to
get the random sublist.
See random/1
for notes on implementation and random seed.
Examples
# Although not necessary, let's seed the random algorithm
iex> :rand.seed(:exsss, {1, 2, 3})
iex> Enum.take_random(1..10, 2)
[3, 1]
iex> Enum.take_random(?a..?z, 5)
'mikel'