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

commonMain.it.unibo.tuprolog.solve.stdlib.primitive.CurrentPrologFlag.kt Maven / Gradle / Ivy

package it.unibo.tuprolog.solve.stdlib.primitive

import it.unibo.tuprolog.core.Atom
import it.unibo.tuprolog.core.Substitution
import it.unibo.tuprolog.core.Term
import it.unibo.tuprolog.solve.ExecutionContext
import it.unibo.tuprolog.solve.primitive.BinaryRelation
import it.unibo.tuprolog.solve.primitive.Solve
import it.unibo.tuprolog.unify.Unificator.Companion.mguWith

object CurrentPrologFlag : BinaryRelation.WithoutSideEffects("current_prolog_flag") {
    override fun Solve.Request.computeAllSubstitutions(
        first: Term,
        second: Term
    ): Sequence =
        context.flags.asSequence()
            .map { (k, v) -> Atom.of(k) to v }
            .map { (k, v) -> (k mguWith first) + (v mguWith second) }
            .filter { it.isSuccess }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy