final case class Coin[A, B](prob: Ex[A], gen: Random)(implicit num: NumDouble[A] { type Boolean = B }, default: HasDefault[B]) extends Ex[B] with Act with ProductWithAdjuncts with Product with Serializable
A random boolean with a given probability. If prob
is zero, the output will
always be false
, if prob
is one, the output will always be true
, if
prob
is 0.5
, the likelihood of false
and true
is equal.
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 coin = gen.coin(0.4) Act( coin, // draw new number PrintLn("Random coin (slightly favouring false): " ++ coin.toStr) // print current value )
Linear Supertypes
Ordering
- Alphabetic
- By Inheritance
Inherited
- Coin
- Serializable
- ProductWithAdjuncts
- Act
- Ex
- Flow
- Lazy
- Product
- Equals
- AnyRef
- Any
- Hide All
- Show All
Visibility
- Public
- Protected
Instance Constructors
- new Coin(prob: Ex[A], gen: Random)(implicit num: NumDouble[A] { type Boolean = B }, default: HasDefault[B])
Type Members
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def adjuncts: List[Adjunct]
- Definition Classes
- Coin → ProductWithAdjuncts
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def expand[T <: Txn[T]](implicit ctx: Context[T], tx: T): Repr[T]
- Definition Classes
- Lazy
- val gen: Random
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def mkRepr[T <: Txn[T]](implicit ctx: Context[T], tx: T): Repr[T]
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- val prob: Ex[A]
- def productElementNames: Iterator[String]
- Definition Classes
- Product
- def productPrefix: String
- Definition Classes
- Coin → Product
- final val ref: AnyRef
- Attributes
- protected
- Definition Classes
- Lazy
- Annotations
- @transient()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def update: Act
Convenient method that returns the
Coin
itself.Convenient method that returns the
Coin
itself. This can be used for additional clarity when writingBang() ---> coin.update
instead ofBang() ---> coin
. - final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated