You can do this, but you have to define something that *should* be defined
for you (and is by random-extra and elm-random-pcg): Random.constant.
import Random
constant x = Random.map (always x) Random.bool
listUntil : Random.Generator a -> (a -> Bool) -> Random.Generator (List a)
listUntil element predicate =
element |> Random.andThen (\elem ->
if predicate elem then
constant [elem] -- or []
else
Random.map (\tail -> elem :: tail) (listUntil element predicate)
)
You can play with the implementation depending on whether or not you want
the last element and whether the predicate should return True or False.
--
You received this message because you are subscribed to the Google Groups "Elm
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.