# HG changeset patch # User Benjamin Weber # Date 1666783262 -7200 # Wed Oct 26 13:21:02 2022 +0200 # Node ID 163533adcd0ed41d3131492f3a7abcbe55c3ba0a # Parent ac81f247eb50cd5c4624c28ee47161988391a92d own implementation of Random.List.choices diff --git a/src/Rework.elm b/src/Rework.elm --- a/src/Rework.elm +++ b/src/Rework.elm @@ -97,7 +97,21 @@ toRework = List.map (\x -> updateRework x NeedsRework) in - Random.map (\( a, b ) -> toRework a ++ b) << Random.List.choices n + Random.map (\( a, b ) -> toRework a ++ b) << choices n + + +choices : Int -> List a -> Random.Generator ( List a, List a ) +choices n xs = + case n of + 0 -> + Random.constant ( [], xs ) + + _ -> + let + xs1 = + Random.List.shuffle xs + in + Random.map2 Tuple.pair (Random.map (List.take n) xs1) (Random.map (List.drop n) xs1) setReworksCmd : Model -> Cmd Msg