[erlang-questions] Erlang 20 and crypto:rand_uniform/2

Raimo Niskanen <>
Mon Aug 14 15:36:47 CEST 2017


On Tue, Aug 08, 2017 at 11:10:33AM -0700, Pierre Fenoll wrote:
> I am sorry but nothing of what you said is even close to a good reason to
> not provide a /2 providing the same API as crypto:rand_uniform/2.

As I see it there is so far no good reason _for_ implementing rand:uniform/2,
and there are at least 2 possible variants:
    rand:uniform(Min, Max) -> Min + rand:uniform(Max - Min).
    rand:uniform(Min, Range) -> Min + rand:uniform(Range).

The current API is minimal, makes both easy and does not choose between them.
Small APIs are in general more beautiful and easier to maintain.

Best regards
-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB


More information about the erlang-questions mailing list