Rand

io.github.srs.utils.random.Rand$package.Rand
object Rand

A companion object for the Rand type, providing utility methods for working with random values.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Rand.type

Members list

Value members

Concrete methods

def flatMap[A, B](ra: () => A)(f: A => () => B): () => B

Transforms a Rand of type A into a Rand of type B by applying the function 'f' to the value generated by the original Rand.

Transforms a Rand of type A into a Rand of type B by applying the function 'f' to the value generated by the original Rand.

Type parameters

A

the type of the value generated by the original Rand.

B

the type of the value generated by the transformed Rand.

Value parameters

f

the function to transform the value of type A into a value of type B.

ra

the original Rand that generates a value of type A.

Attributes

Returns

a new Rand that generates a value of type B.

def listOfN[A](n: Int, ra: () => A): () => List[A]

Creates a Rand that generates a list of 'n' random values of type A using the provided Rand.

Creates a Rand that generates a list of 'n' random values of type A using the provided Rand.

Type parameters

A

the type of the random values to be generated.

Value parameters

n

the number of random values to generate.

ra

the Rand that generates a single random value of type A.

Attributes

Returns

a new Rand that generates a list of 'n' random values of type A.

def map[A, B](ra: () => A)(f: A => B): () => B

Transforms a Rand of type A into a Rand of type B by applying the function 'f' to the value generated by the original Rand.

Transforms a Rand of type A into a Rand of type B by applying the function 'f' to the value generated by the original Rand.

Type parameters

A

the type of the value generated by the original Rand.

B

the type of the value generated by the transformed Rand.

Value parameters

f

the function to transform the value of type A into a value of type B.

ra

the original Rand that generates a value of type A.

Attributes

Returns

a new Rand that generates a value of type B.

def unit[A](a: A): () => A

Creates a Rand that always returns the same value 'a' along with the current RNG state.

Creates a Rand that always returns the same value 'a' along with the current RNG state.

Type parameters

A

the type of the value to be returned.

Value parameters

a

the value to be returned by the Rand.

Attributes

Returns

a Rand that returns 'a' and the current RNG state.