Module RushCheck::HsRandom
In: rushcheck/random.rb

HsRandom module provides several random number function with the functional random generator. This module is implemented Haskell\’s System.Random library. This module assumes that the class which includes HsRandom should have an instance method random_range to generate a random number and a new random number generator. It assumes also that the class which includes HsRandom should have a class method bound to give a bound of random numbers.

Methods

Public Instance methods

random requires the functional random number generater (StdGen object) and optionally requires the bound of random numbers. It returns an array with length 2, where the first component should be a new random number, and the last should be a new random number generator.

random_array requires the functional random number generater (StdGen object). Optionally, it requires the length of results and the bound of random numbers. This method returns different result whether the second argument length is nil or not. When the second argument is nil, then random_array returns a Proc which takes one variable as an integer and return a new random value, such as an infinite sequence of random numbers. Otherwise, the second argument of random_array is not nil but some integer, then random_array returns an array of random numbers with the length.

random_std requires optionally the bound of random numbers. It returns an array with length 2, where the first component should be a new random number, and the last should be a new random number generator. This method uses the unique standard random generator TheStdGen.

[Validate]