2013-02-22 23:19:40 +00:00
|
|
|
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
|
|
|
|
@docs range, float
|
|
|
|
-}
|
|
|
|
|
2013-07-29 17:26:53 +00:00
|
|
|
import Signal (Signal)
|
2013-07-29 21:23:04 +00:00
|
|
|
import Native.Random
|
2013-03-13 07:00:02 +00:00
|
|
|
|
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.
|
|
|
|
-}
|
2013-03-10 09:07:17 +00:00
|
|
|
range : Int -> Int -> Signal a -> Signal Int
|
2013-07-29 21:23:04 +00:00
|
|
|
range = Native.Random.range
|
2013-03-10 09:07:17 +00:00
|
|
|
|
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).
|
|
|
|
-}
|
2013-03-10 09:07:17 +00:00
|
|
|
float : Signal a -> Signal Float
|
2013-10-17 15:50:08 +00:00
|
|
|
float = Native.Random.float_
|
2013-10-06 13:55:56 +00:00
|
|
|
|
|
|
|
{-| 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
|