commonMain.it.unibo.tuprolog.solve.streams.solver.fsm.AlreadyExecutedState.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of solve-streams-jvm Show documentation
Show all versions of solve-streams-jvm Show documentation
Experimental, functional-programming-based implementation of Prolog's SLDNF resolution principle
package it.unibo.tuprolog.solve.streams.solver.fsm
/**
* A wrapper class representing States that should not be executed again, because they've already executed their behaviour
*
* @author Enrico
*/
internal class AlreadyExecutedState(internal val wrappedState: State) : State by wrappedState {
override val hasBehaved: Boolean = true
override fun toString(): String = "AlreadyExecutedState of: $wrappedState"
}
/** Extension method to wrap a [State], marking it as already executed */
internal fun State.asAlreadyExecuted(): AlreadyExecutedState =
(this as? AlreadyExecutedState)
?.let { it }
?: AlreadyExecutedState(this)