on 8a2fc7c help sign in
elk/libraries/Random.elm
30 lines 920 B history raw
1module Random where
3{-| Since the core of Elm is pure, randomness must be handled via signals.
5# Random Numbers
6@docs range, float, floatList
7-}
9import Signal (Signal)
10import Native.Random
12{-| Given a range from low to high and a signal of values, this produces
13a new signal that changes whenever the input signal changes. The new
14values are random number between 'low' and 'high' inclusive.
15-}
16range : Int -> Int -> Signal a -> Signal Int
17range = Native.Random.range
19{-| Produces a new signal that changes whenever the input signal changes.
20The new values are random numbers in [0..1).
21-}
22float : Signal a -> Signal Float
23float = Native.Random.float_
25{-| Produces a new signal of lists that changes whenever the input signal
26changes. The input signal specifies the length of the random list. Each value is
27a random number in [0..1).
28-}
29floatList : Signal Int -> Signal [Float]
30floatList = Native.Random.floatList