Numeric

interface Numeric: Constant, Any

Fields

Name Description
open isNumber: Boolean

Checks whether the current term is a number, i.e., either an integer or a real number. This method is guaranteed to return true if and only if the current term is an instance of Numeric.

open variables: Sequence<Var>

The sequence of Variables directly or indirectly contained in the current term. Variables are lazily returned in a non-deterministic order. Notice that no occurrence-check is performed. Thus, if a Term contains the same Variable twice or more times, then the variables sequence may contain as many occurrences of that Variable

abstract decimalValue: BigDecimal
abstract intValue: BigInteger

Methods

freshCopy

abstract fun freshCopy(): Numeric

Returns a fresh copy of this Term, that is, an instance of Term which is equal to the current one in any aspect, except variables directly or indirectly contained into this Term, which are refreshed. This means that it could return itself, if no variable is present (ground term), or a new Term with freshly generated variables.

Variables are refreshed consistently, meaning that, if more variables exists within this Term having the same name, all fresh copies of such variables will have the same complete name.

Example: "f(X, g(X))".freshCopy() returns something like "f(X_1, g(X_1))" instead of "f(X_1, g(X_2))"

Notice that, if the current term is ground, the same object may be returned as a result by this method.

ReturnValue

Name Description
Numeric

a fresh copy of the current term which is different because variables are consistently renamed

freshCopy

abstract fun freshCopy(scope: Scope): Numeric

Returns a fresh copy of this Term, similarly to freshCopy, possibly reusing variables from the provided scope, if any

Parameters

Name Description
scope: Scope

the Scope containing variables to be used in copying

ReturnValue

Name Description
Numeric

a fresh copy of the current term which is different because variables are consistently renamed

compareValueTo

open fun compareValueTo(other: Numeric): Int

Parameters

Name Description
other: Numeric

ReturnValue

Name Description
Int

asNumeric

open fun asNumeric(): Numeric

Casts the current Term to Numeric, if possible, or returns null otherwise

ReturnValue

Name Description
Numeric

the current Term, casted to Numeric, or null, if the current term is not an instance of Numeric

Extensions

toClause

fun Term.toClause(source: Any?, line: Int, column: Int): Clause

Receiver

Name Description
Term

Parameters

Name Description
source: Any?
line: Int
column: Int

ReturnValue

Name Description
Clause

unfoldGoals

fun Term.unfoldGoals(): Sequence<Term>

Receiver

Name Description
Term

ReturnValue

Name Description
Sequence<Term>

toGoals

fun Term.toGoals(): Cursor<Term>

Receiver

Name Description
Term

ReturnValue

Name Description
Cursor<Term>

isWellFormed

fun Term.isWellFormed(): Boolean

Check whether the receiver term is a well-formed predication

Receiver

Name Description
Term

ReturnValue

Name Description
Boolean

prepareForExecutionAsGoal

fun Term.prepareForExecutionAsGoal(): Struct

Prepares the receiver Goal for execution

For example, the goal A is transformed, after preparation for execution, as the Term: call(A)

Receiver

Name Description
Term

ReturnValue

Name Description
Struct

evalAsExpression

fun Term.evalAsExpression(request: Request<*>, index: Int?): Term

Receiver

Name Description
Term

Parameters

Name Description
request: Request<*>
index: Int?

ReturnValue

Name Description
Term

evalAsArithmeticExpression

fun Term.evalAsArithmeticExpression(request: Request<*>, index: Int?): Numeric

Receiver

Name Description
Term

Parameters

Name Description
request: Request<*>
index: Int?

ReturnValue

Name Description
Numeric

eq

infix fun Term.eq(that: Term): Equation

Creates an equation with this and that terms

Receiver

Name Description
Term

Parameters

Name Description
that: Term

ReturnValue

Name Description
Equation

CompanionObject

Numeric

interface Numeric: Constant, Any

Fields

Name Description
val INTEGER_PATTERN: @JvmField
val REAL_PATTERN: @JvmField

Methods

of

fun of(decimal: BigDecimal): Real

Parameters

Name Description
decimal: BigDecimal

ReturnValue

Name Description
Real

of

fun of(decimal: Double): Real

Parameters

Name Description
decimal: Double

ReturnValue

Name Description
Real

of

fun of(decimal: Float): Real

Parameters

Name Description
decimal: Float

ReturnValue

Name Description
Real

of

fun of(integer: BigInteger): Integer

Parameters

Name Description
integer: BigInteger

ReturnValue

Name Description
Integer

of

fun of(integer: Int): Integer

Parameters

Name Description
integer: Int

ReturnValue

Name Description
Integer

of

fun of(integer: Long): Integer

Parameters

Name Description
integer: Long

ReturnValue

Name Description
Integer

of

fun of(integer: Short): Integer

Parameters

Name Description
integer: Short

ReturnValue

Name Description
Integer

of

fun of(integer: Byte): Integer

Parameters

Name Description
integer: Byte

ReturnValue

Name Description
Integer

of

fun of(value: Number): Numeric

Parameters

Name Description
value: Number

ReturnValue

Name Description
Numeric

of

fun of(number: String): Numeric

Parameters

Name Description
number: String

ReturnValue

Name Description
Numeric

Extensions

parse

fun Numeric.Companion.parse(input: String, operators: OperatorSet): Numeric

Receiver

Name Description
Numeric.Companion

Parameters

Name Description
input: String
operators: OperatorSet

ReturnValue

Name Description
Numeric

parse

fun Numeric.Companion.parse(input: String): Numeric

Receiver

Name Description
Numeric.Companion

Parameters

Name Description
input: String

ReturnValue

Name Description
Numeric