commonMain.it.unibo.tuprolog.solve.function.ArithmeticUtils.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of solve-jvm Show documentation
Show all versions of solve-jvm Show documentation
Resolution-agnostic API for logic solvers
package it.unibo.tuprolog.solve.function
import it.unibo.tuprolog.core.Numeric
import it.unibo.tuprolog.core.Term
import it.unibo.tuprolog.solve.ExecutionContext
import it.unibo.tuprolog.solve.primitive.Solve
private fun Term.eval(
request: Solve.Request,
index: Int? = null,
evaluator: (Solve.Request, Int?) -> AbstractEvaluator,
): T = accept(evaluator(request, index))
private fun Term.eval(
request: Solve.Request,
evaluator: (Solve.Request) -> AbstractEvaluator,
): T = accept(evaluator(request))
fun Term.evalAsExpression(
request: Solve.Request<*>,
index: Int? = null,
): Term = eval(request, index, ::ExpressionEvaluator)
fun Term.evalAsArithmeticExpression(
request: Solve.Request<*>,
index: Int? = null,
): Numeric = eval(request, index, ::ArithmeticEvaluator)