ExpressionMonoFunction

com.phasmidsoftware.number.expression.expr.ExpressionMonoFunction
See theExpressionMonoFunction companion object
sealed abstract class ExpressionMonoFunction(val name: String, val f: Eager => Eager, val parity: Parity) extends ExpressionFunction[Eager]

A lazy monadic expression function.

TODO need to mark whether this function is exact or not (but I can't think of many which are exact).

TODO implement also for other Valuables than Numbers.

Value parameters

f

the function Number => Number.

name

the name of this function.

Attributes

Companion
object
Graph
Supertypes
trait Eager => Valuable
class Object
trait Matchable
class Any
Known subtypes
object Exp
class Hyperbolic
object Cosh
object Sinh
object Ln
object Negate
object Reciprocal
class SineCos
object Cosine
object Sine
Show all

Members list

Value members

Abstract methods

def applyExact(x: Eager): Option[Eager]

Attempts to evaluate the given Valuable exactly using this ExpressionMonoFunction. If the operation can be performed exactly, it returns the resulting Valuable wrapped in an Option. If the operation cannot be performed exactly, it returns None.

Attempts to evaluate the given Valuable exactly using this ExpressionMonoFunction. If the operation can be performed exactly, it returns the resulting Valuable wrapped in an Option. If the operation cannot be performed exactly, it returns None.

Value parameters

x

the input parameter of type Valuable to be evaluated.

Attributes

Returns

an Option containing the exact result as a Valuable if the evaluation succeeds, or None if it does not.

def paramContext(context: Context): Context

Specifies the context in which the parameter of the function f must be evaluated.

Specifies the context in which the parameter of the function f must be evaluated.

Value parameters

context

the Context in which this ExpressionMonoFunction must be evaluated.

Attributes

Returns

the Context to be used when evaluating the parameter.

Concrete methods

def apply(x: Eager): Eager

Evaluate this function on Valuable x.

Evaluate this function on Valuable x.

Value parameters

x

the parameter to the function.

Attributes

Returns

the result of f(x).

def applyComplex(z: Complex): Option[Eager]

Applies the mathematical operation encapsulated by this ExpressionMonoFunction to the given complex number. The operation is determined based on the specific subtype or case of this function instance.

Applies the mathematical operation encapsulated by this ExpressionMonoFunction to the given complex number. The operation is determined based on the specific subtype or case of this function instance.

Value parameters

z

the input complex number of type algebra.eager.Complex to which the operation will be applied

Attributes

Returns

an Option[Eager] containing the result of applying the operation as an Eager instance, or None if the operation is not supported for this function instance

def evaluate(a: Expression)(context: Context): Option[Eager]

Evaluates the given Expression in the specified Context and attempts to derive an Eager result. This method relies on the Expression being evaluated as-is and applies this function's exact logic if applicable.

Evaluates the given Expression in the specified Context and attempts to derive an Eager result. This method relies on the Expression being evaluated as-is and applies this function's exact logic if applicable.

CONSIDER the alternative version (commented out) which seems like it should be correct but isn't.

Value parameters

a

the Expression to be evaluated.

context

the Context within which the evaluation is performed.

Attributes

Returns

an Option[Eager] containing the result of the evaluation if successful, or None otherwise.

override def toString: String

Generate helpful debugging information about this ExpressionMonoFunction.

Generate helpful debugging information about this ExpressionMonoFunction.

Attributes

Returns

a String.

Definition Classes
Function1 -> Any

Inherited methods

def andThen[A](g: Valuable => A): Eager => A

Composes two instances of Function1 in a new Function1, with this function applied first.

Composes two instances of Function1 in a new Function1, with this function applied first.

Type parameters

A

the result type of function g

Value parameters

g

a function R => A

Attributes

Returns

a new function f such that f(x) == g(apply(x))

Inherited from:
Function1
def compose[A](g: A => Eager): A => Valuable

Composes two instances of Function1 in a new Function1, with this function applied last.

Composes two instances of Function1 in a new Function1, with this function applied last.

Type parameters

A

the type to which function g can be applied

Value parameters

g

a function A => T1

Attributes

Returns

a new function f such that f(x) == apply(g(x))

Inherited from:
Function1

Concrete fields

val f: Eager => Eager
val name: String

Returns the name of the expression function.

Returns the name of the expression function.

Attributes

Returns

a string representing the name of the function

val parity: Parity