lundi 3 décembre 2018

Create list with random and unique numbers

I'm trying to make a list of unique, random integers of a certain length.

end_list = for x <- 0..10, do: :rand.uniform(50)
> [41, 9, 8, 50, 49, 1, 1, 7, 7, 47, 20]

What can I write to convey an "if not already present" condition in the do: block?




Aucun commentaire:

Enregistrer un commentaire