[erlang-patches] lists:shuffle

Bob Ippolito <>
Wed Mar 31 16:58:10 CEST 2010

2010/3/31 Björn Gustavsson <>:
> (Please keep the discussion on the mailing list. I have
> added back a CC to the list.)
> 2010/3/31 William v Doorn <>:
>> Hello,
>> It's been implemented in the "standard" libaries of like every popular
>> langauge. It basically shuffles the list. Here are two examples of
>> implemenations:
>> - Python: http://docs.python.org/library/random.html (Scroll down a bit)
>> - Java:
>> http://java.sun.com/j2se/1.4.2/docs/api/java/util/Collections.html#shuffle(java.util.List)
> I think that we might consider adding a shuffle() function to the
> 'random' module.
> Could you show us your Erlang implementation shuffle() function that you
> considered too slow. Perhaps it can be optimized to be fast enough. We
> will need a reference implementation anyway, because we will not add
> any new BIFs before benchmarking them to see whether the performance
> improvement is significant enough.

It would be nice if the shuffle function provided a function and state
parameter for entropy so that you could decide whether to use
something deterministic (e.g. the functional API to random) or a
different source (e.g. the crypto module).

A shuffle function is something we'd find useful, but we've gotten by
without actually implementing a full and correct shuffle


More information about the erlang-patches mailing list