-
Notifications
You must be signed in to change notification settings - Fork 0
/
anonymous.go
executable file
·43 lines (32 loc) · 1.41 KB
/
anonymous.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package suiron
// This file defines the anonymous variable ($_). The anonymous
// variable unifies with any term. It is used when the term which
// it unifies with is irrelevant.
//
// Cleve Lendon
type Anonymous struct {}
var anon Anonymous = Anonymous{}
// Anon - returns the anonymous variable ($_).
func Anon() Anonymous { return anon }
// String - return this term as a string.
func (a Anonymous) String() string { return "$_" }
// TermType - Returns an integer constant which identifies the type.
func (a Anonymous) TermType() int { return ANONYMOUS }
// Unify - unifies a variable with another unifiable expression.
// For the anonymous variable ($_), no substitution necessary.
func (a Anonymous) Unify(other Unifiable, ss SubstitutionSet) (SubstitutionSet, bool) {
return ss, true
} // Unify
// RecreateVariables - creates unique variables every time the
// inference engine fetches a rule from the knowledge base. For the
// anonymous variable, RecreateVariables() simply returns itself.
// This function satisfies the Expression interface.
func (a Anonymous) RecreateVariables(vars VarMap) Expression {
return a
}
// ReplaceVariables - replaces a bound variable with its binding.
// For the anonymous variable, ReplaceVariables() simply returns itself.
// This function satisfies the Expression interface.
func (a Anonymous) ReplaceVariables(ss SubstitutionSet) Expression {
return a
} // ReplaceVariables()