Skip to content

Commit

Permalink
fix FunctorNode
Browse files Browse the repository at this point in the history
  • Loading branch information
gciatto committed May 24, 2020
1 parent 4e1fdcd commit 333297e
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import it.unibo.tuprolog.core.Clause
import it.unibo.tuprolog.core.Var
import it.unibo.tuprolog.unify.Unificator.Companion.matches
import it.unibo.tuprolog.utils.Cached
import it.unibo.tuprolog.utils.buffered
import it.unibo.tuprolog.utils.dequeOf

internal sealed class FunctorNode : ReteNode {
Expand Down Expand Up @@ -138,13 +137,17 @@ internal sealed class FunctorNode : ReteNode {

override fun retractAllIndexed(clause: Clause): Sequence<SituatedIndexedClause> =
if (clause.isGlobal()) {
Utils.merge(
val partialResult = Utils.merge(
arities.values.map {
it.extractGlobalIndexedSequence(clause)
})
.filter { it.innerClause matches clause }
.map { it.removeFromIndex(); it }
.buffered()
.toList()
if (partialResult.isNotEmpty()) {
invalidateCache()
partialResult.forEach { it.removeFromIndex() }
}
partialResult.asSequence()
}
else {
arities[clause.nestedArity()]?.retractAllIndexed(clause)?.invalidatingCacheIfNonEmpty()
Expand Down

0 comments on commit 333297e

Please sign in to comment.