Range

final case class Range[A](lo: Ex[A], hi: Ex[A], gen: Random)(num: Num[A]) extends Ex[A] with Act with ProductWithAdjuncts

A random number between a given lo and a given hi boundary. The boundaries are inclusive for integer numbers. For floating point numbers, the hi bound is exclusive.

A random number between a given lo and a given hi boundary. The boundaries are inclusive for integer numbers. For floating point numbers, the hi bound is exclusive.

This is both an expression and an action. The action draws a new random number, the expression reports the last drawn value.

Example:

 val gen = Random()
 val r1to10 = gen.range(1, 10)
 Act(
   r1to10, // draw new number
   PrintLn("Random number (1 to 10): " ++ r1to10.toStr)  // print current value
 )
Companion
object
trait Serializable
trait ProductWithAdjuncts
trait Act
trait Ex[A]
trait Lazy
trait Product
trait Equals
class Object
trait Matchable
class Any

Type members

Types

type Repr[T <: Txn[T]] = IExpr[T, A] & IAction[T]

Value members

Concrete methods

override def adjuncts: List[Adjunct]
Definition Classes
ProductWithAdjuncts
override def productPrefix: String
Definition Classes
Product
def update: Act

Convenient method that returns the Range itself. This can be used for additional clarity when writing Bang() ---> x.update instead of Bang() ---> x.

Convenient method that returns the Range itself. This can be used for additional clarity when writing Bang() ---> x.update instead of Bang() ---> x.

Inherited methods

def productElementNames: Iterator[String]
Inherited from
Product
def productIterator: Iterator[Any]
Inherited from
Product

Inherited fields

@transient
final protected val ref: Object
Inherited from
Lazy