From e52f64b61d4d29a2e5a1b1152744a226e2aa0218 Mon Sep 17 00:00:00 2001 From: Giuseppe Pisano Date: Tue, 16 Jun 2020 19:02:35 +0200 Subject: [PATCH] Functor/3 fix --- .../unibo/tuprolog/solve/stdlib/primitive/Functor.kt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Functor.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Functor.kt index b9ce06b1c..d650a13d4 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Functor.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Functor.kt @@ -30,7 +30,10 @@ object Functor : TernaryRelation.Functional("functor") { Substitution.failed() } is Var -> { - Substitution.of(third to Integer.of(first.arity)) + if (first.functor == second.value) + Substitution.of(third to Integer.of(first.arity)) + else + Substitution.failed() } else -> { // TODO expected here should be INTEGER | VARIABLE @@ -41,7 +44,10 @@ object Functor : TernaryRelation.Functional("functor") { is Var -> { when (third) { is Numeric -> { - Substitution.of(second to Atom.of(first.functor)) + if (first.arity == third.intValue.toInt()) + Substitution.of(second to Atom.of(first.functor)) + else + Substitution.failed() } is Var -> { Substitution.of(