elm/libraries/Random.elm

31 lines
920 B
Elm
Raw Normal View History

module Random where
2013-09-10 17:04:38 +00:00
{-| Since the core of Elm is pure, randomness must be handled via signals.
# Random Numbers
2013-10-18 05:26:04 +00:00
@docs range, float, floatList
2013-09-10 17:04:38 +00:00
-}
import Signal (Signal)
import Native.Random
2013-09-10 17:04:38 +00:00
{-| Given a range from low to high and a signal of values, this produces
a new signal that changes whenever the input signal changes. The new
values are random number between 'low' and 'high' inclusive.
-}
range : Int -> Int -> Signal a -> Signal Int
range = Native.Random.range
2013-09-10 17:04:38 +00:00
{-| Produces a new signal that changes whenever the input signal changes.
The new values are random numbers in [0..1).
-}
float : Signal a -> Signal Float
float = Native.Random.float_
{-| Produces a new signal of lists that changes whenever the input signal
changes. The input signal specifies the length of the random list. Each value is
a random number in [0..1).
-}
floatList : Signal Int -> Signal [Float]
floatList = Native.Random.floatList