Package-level declarations

Types

Link copied to clipboard
abstract class AbstractEvaluator<E : ExecutionContext, T : Term>(request: Solve.Request<E>, index: Int?) : TermVisitor<T>

Base TermVisitor for reducing an expression Term to a value of type T, recursively resolving any Struct sub-term whose Signature matches a LogicFunction loaded in request's it.unibo.tuprolog.solve.library.Runtime (loadedFunctions) into that function's Compute.Response.result. A Struct matching no loaded function is handled by unevaluable (by default, an error).

Link copied to clipboard

Evaluates an expression as a Numeric term. Throws a TypeError in case a non-evaluable sub-term is met. Throws a TypeError in case the evaluation produces a non-numeric term.

Link copied to clipboard
abstract class BinaryMathFunction(name: String) : MathFunction

Base class to implement unary math functions

Link copied to clipboard
sealed class Compute

A base class for Computation requests and responses

Link copied to clipboard

Evaluates a Term as an expression, w.r.t. the loaded functions provided through request. Throws a TypeError in case a non-evaluable sub-term is met.

Link copied to clipboard
class ExpressionReducer<E : ExecutionContext>(request: Solve.Request<E>, index: Int? = null) : AbstractEvaluator<E, Term>

Reduces a Term as an expression by evaluating all the evaluable sub-terms it contains w.r.t. the loaded functions provided through request. If the input expression is non-evaluable, it remains unaffected and no error is thrown

Link copied to clipboard

A class wrapping a LogicFunction implementation

Link copied to clipboard

Base class to implement math functions accepting only integers

Link copied to clipboard
fun interface LogicFunction

A typealias for a prolog function that accepts a Compute.Request and returns a Compute.Response

Link copied to clipboard

Base class to implement arithmetic functions

Link copied to clipboard
abstract class NullaryMathFunction(name: String) : MathFunction

Base class to implement nullary math functions (with no arguments)

Link copied to clipboard
abstract class UnaryMathFunction(name: String) : MathFunction

Base class to implement unary math functions

Functions

Link copied to clipboard
fun Term.evalAsArithmeticExpression(request: Solve.Request<*>, index: Int? = null): Numeric

Evaluates this Term as a full arithmetic expression (as is/2 does), via ArithmeticEvaluator, producing a Numeric result or raising an error if any sub-term is not evaluable, or does not evaluate to a number. index is used only to enrich thrown errors, identifying which argument of request this term came from.

Link copied to clipboard
fun Term.evalAsExpression(request: Solve.Request<*>, index: Int? = null): Term

Evaluates this Term as an expression against request's context-loaded functions, reducing evaluable sub-terms in place via ExpressionEvaluator; a non-evaluable sub-term raises a it.unibo.tuprolog.solve.exception.error.TypeError. index is used only to enrich that error, identifying which argument of request this term came from.