IsIntegral

com.phasmidsoftware.number.expression.expr.IsIntegral
object IsIntegral

Provides a mechanism to determine whether an Expression can be represented as an integer value and, if so, extracts the corresponding integer value.

The IsIntegral object acts as an extractor, allowing pattern matching against Expression instances to identify those that represent whole numbers. This is particularly useful when working with complex expressions that may or may not simplify to integers.

Attributes

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

Members list

Value members

Concrete methods

def unapply(expr: Expression): Option[Int]

Extractor method for determining if an Expression represents an integer value.

Extractor method for determining if an Expression represents an integer value.

This method attempts to match the given Expression and identify if it can be reduced to an integer value. If the Expression is a ValueExpression containing a WholeNumber, or a Rational that is an integer (i.e., it has no fractional part), the corresponding integer value is returned.

Value parameters

expr

the Expression to be analyzed for possible extraction of an integer value

Attributes

Returns

an Option[Int] containing the integer value if the input expression can be reduced to an integer, or None otherwise