IO Operators
This commit is contained in:
parent
b9f419a59d
commit
82a8fccf87
22 changed files with 450 additions and 199 deletions
|
@ -6,7 +6,7 @@ abstract class Operator(
|
|||
private val symbol: Atom,
|
||||
private val leftOperand: Operand? = null,
|
||||
private val rightOperand: Operand
|
||||
) : CompoundTerm(symbol, listOfNotNull(leftOperand, rightOperand)) {
|
||||
) : CompoundTerm(symbol, listOfNotNull(leftOperand, rightOperand)), Term {
|
||||
override fun toString(): String {
|
||||
return when (leftOperand) {
|
||||
null -> "${symbol.name} $rightOperand"
|
||||
|
|
|
@ -22,4 +22,15 @@ open class Structure(val name: Atom, var arguments: List<Argument>) : Goal(), He
|
|||
else -> "${name.name}(${arguments.joinToString(", ")})"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other !is Structure) return false
|
||||
if (functor != other.functor) return false
|
||||
return arguments.zip(other.arguments).all { (a, b) -> a == b }
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return javaClass.hashCode()
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue