vendredi 20 mai 2016

How can I randomly generate a pair of floats in Elm?

I am trying to create a Random.Generator (Float, Float) where the first Float is in some range say 0.0 1000.0 and the second between 0.0 and the first value.

Example of valid values: (12.0, 5.0) Invalid: (303.0, 800.0)

I looked over code in Random.Extra module but I wasn't able to find my way around.

The example bellow don't even compile. :)

tuple = 
  let range = float 0.0 500.0
  flatMap (\max -> (max, float 0.0 max)) range




Aucun commentaire:

Enregistrer un commentaire