diff --git a/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateGoalEvaluation.kt b/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateGoalEvaluation.kt index 4b6631591..a77425d26 100644 --- a/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateGoalEvaluation.kt +++ b/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateGoalEvaluation.kt @@ -1,6 +1,7 @@ package it.unibo.tuprolog.solve.solver.fsm.impl import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.solve.SideEffect import it.unibo.tuprolog.solve.Solution import it.unibo.tuprolog.solve.StreamsSolver import it.unibo.tuprolog.solve.currentTimeInstant @@ -41,9 +42,12 @@ internal class StateGoalEvaluation( responses = StreamsSolver.solveToResponses(solve.newThrowSolveRequest(prologError)) } + var allSideEffectsSoFar = emptyList() responses?.forEach { - yield(ifTimeIsNotOver(stateEnd(it))) + allSideEffectsSoFar = allSideEffectsSoFar + it.sideEffects + + yield(ifTimeIsNotOver(stateEnd(it.copy(sideEffects = allSideEffectsSoFar)))) if (it.solution is Solution.Halt) return@sequence // if halt reached, overall computation should stop }