elm-community / random-extra / Random.List

Extra randomized functions on lists.

Work with a List

choose : List a -> Random.Generator ( Maybe a, List a )

Sample without replacement: produce a randomly selected element of the list, and the list with that element omitted. If the list is empty, the selected element will be Nothing.

shuffle : List a -> Random.Generator (List a)

Shuffle the list. Takes O(n log n) time and no extra space.

choices : Basics.Int -> List a -> Random.Generator ( List a, List a )

Repeated sample without replacement: produce a list of randomly selected elements of some list, and the list of unselected elements.