RandomDSL

io.github.srs.utils.random.RandomDSL
object RandomDSL

A domain-specific language (DSL) for generating random values using a Rand type.

Attributes

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

Members list

Value members

Concrete methods

infix def positive: () => Int

Generates a random positive integer value using the provided RNG.

Generates a random positive integer value using the provided RNG.

Attributes

Returns

a Rand that generates a random positive integer.

infix def randomBoolean: () => Boolean

Generates a random boolean value using the provided RNG.

Generates a random boolean value using the provided RNG.

Attributes

Returns

a Rand that generates a random boolean.

infix def randomDouble: () => Double

Generates a double value within the range [0.0, 1.0) using the provided RNG.

Generates a double value within the range [0.0, 1.0) using the provided RNG.

Attributes

Returns

a Rand that generates a random double.

infix def randomInt: () => Int

Generates a random integer value using the provided RNG.

Generates a random integer value using the provided RNG.

Attributes

Returns

a Rand that generates a random integer.

infix def randomLong: () => Long

Generates a long value using the provided RNG.

Generates a long value using the provided RNG.

Attributes

Returns

a Rand that generates a random long.

Extensions

Extensions

extension (f: Boolean => () => Double)
infix def excludeMax: () => Double

Generates a random double value within the range [start, end) excluding the maximum value.

Generates a random double value within the range [start, end) excluding the maximum value.

Attributes

Returns

a Rand that generates a random double value, excluding the maximum value.

infix def includeMax: () => Double

Generates a random double value within the range [start, end] including the maximum value.

Generates a random double value within the range [start, end] including the maximum value.

Attributes

Returns

a Rand that generates a random double value, including the maximum value.

extension (i: Int)
infix def randomString: () => String

Generates a random string of length i using the provided RNG.

Generates a random string of length i using the provided RNG.

Attributes

Returns

a Rand that generates a random string of length i.

infix def times[A](ra: () => A): () => List[A]

Generates a list of random values of type A using the provided Rand and the specified size i.

Generates a list of random values of type A using the provided Rand and the specified size i.

Type parameters

A

the type of the random values to generate.

Value parameters

ra

the Rand to use for generating the random values.

Attributes

Returns

a Rand that generates a list of random values of type A of size i.

extension (rng: RNG)
infix def generate[A](rand: () => A): (A, RNG)

Generates a random value using the provided RNG.

Generates a random value using the provided RNG.

Type parameters

A

the type of the random value to generate.

Value parameters

rand

the Rand to use for generating the random value.

Attributes

Returns

a tuple containing the generated random value and the next state of the RNG.

extension [A](seq: Seq[A])
infix def shuffle: () => Seq[A]

Generates a shuffled version of the list using the provided RNG.

Generates a shuffled version of the list using the provided RNG.

Attributes

Returns

a Rand that produces a tuple: the shuffled list and the next RNG state.

extension (start: Double)
infix def to(end: Double): Boolean => () => Double

Generates a random double value within the range [start, end) or [start, end] based on the isMaxExcluded parameter.

Generates a random double value within the range [start, end) or [start, end] based on the isMaxExcluded parameter.

Value parameters

end

the end of the range (exclusive or inclusive based on isMaxExcluded).

Attributes

Returns

a function that takes a boolean indicating whether the maximum value is excluded and returns a Rand that generates a random double.