Пример #1
0
 /// <summary>
 /// All we have to do here is check whether this is one of the variables we're looking for.
 /// </summary>
 public override object AlphaConvert(List<LogicVariable> oldVars, LogicVariable[] newVars, PrologContext context, bool evalIndexicals)
 {
     var index = oldVars.IndexOf(this);
     if (index < 0)
         return this;
     return newVars[index] ?? (newVars[index] = new LogicVariable(this.Name));
 }
Пример #2
0
 static object CanonicalizeWithExplicitBindingList(object value, List<LogicVariable> vars, List<object> values)
 {
     value = Deref(value);
     if (vars == null)
         return value;
     var lv = value as LogicVariable;
     while (lv != null)
     {
         int bindingPosition;
         if ((bindingPosition = vars.IndexOf(lv)) >= 0)
         {
             // it's aliased by the binding list
             value = values[bindingPosition];
             lv = value as LogicVariable;
         }
         else
             // It's not in the binding list, so we're done.
             return value;
     }
     return value;
 }