All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.it.unibo.tuprolog.solve.function.ArithmeticUtils.kt Maven / Gradle / Ivy

There is a newer version: 1.0.4
Show newest version
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)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy