mardi 26 janvier 2016

Elm random list implementation

Elm standard library offers a function to generate random lists that works fine. By taking a look at its implementation, we can see that the list is constructed in a functionnal style, i.e. from the end to the beginning. When enough elements have been generated, the reversed list is returned:

if n < 1 then
    (List.reverse list, seed)

I'm wondering why do we need to reverse this list? Is it necessary to ensure "correct" randomness?




Aucun commentaire:

Enregistrer un commentaire