Checkpoint
This commit is contained in:
parent
e3c84e1761
commit
e73e5cbfc8
32 changed files with 1354 additions and 92 deletions
|
@ -1,7 +1,7 @@
|
|||
package prolog.ast.terms
|
||||
|
||||
import prolog.ast.logic.Resolvent
|
||||
import prolog.builtins.equivalent
|
||||
import prolog.logic.equivalent
|
||||
import prolog.logic.Substituted
|
||||
import prolog.logic.unifyLazy
|
||||
|
||||
|
@ -9,13 +9,19 @@ typealias Argument = Term
|
|||
|
||||
typealias CompoundTerm = Structure
|
||||
|
||||
open class Structure(val name: Atom, val arguments: List<Argument>) : Goal(), Head, Body, Resolvent {
|
||||
open class Structure(val name: Atom, var arguments: List<Argument>) : Goal(), Head, Body, Resolvent {
|
||||
override val functor: Functor = "${name.name}/${arguments.size}"
|
||||
|
||||
override fun solve(goal: Goal, subs: Substituted): Sequence<Substituted> {
|
||||
return unifyLazy(goal, this, subs)
|
||||
}
|
||||
|
||||
// A structure does not need to be evaluated, so return an empty sequence.
|
||||
override fun evaluate(subs: Substituted): Pair<Term, Substituted> = Pair(this, emptyMap())
|
||||
|
||||
/**
|
||||
* See also [SWI Prolog Standard Order of Terms](https://www.swi-prolog.org/pldoc/man?section=standardorder)
|
||||
*/
|
||||
override fun compareTo(other: Term): Int {
|
||||
when (other) {
|
||||
is Structure -> {
|
||||
|
|
Reference in a new issue