public bool termEqual(object term) { term = YP.getValue(term); if (term is Functor1) { Functor1 termFunctor = (Functor1)term; return(_name.Equals(termFunctor._name) && YP.termEqual(_arg1, termFunctor._arg1)); } return(false); }
public bool termEqual(object term) { if (_isBound) { return(YP.termEqual(getValue(), term)); } else { return(this == YP.getValue(term)); } }
public bool lessThan(Functor2 functor) { // Do the equal check first since it is faster. if (!_name.Equals(functor._name)) { return(_name.lessThan(functor._name)); } if (!YP.termEqual(_arg1, functor._arg1)) { return(YP.termLessThan(_arg1, functor._arg1)); } return(YP.termLessThan(_arg2, functor._arg2)); }
public bool Equals(object[] array1, object[] array2) { if (array1.Length != array2.Length) { return(false); } for (int i = 0; i < array1.Length; ++i) { if (!YP.termEqual(array1[i], array2[i])) { return(false); } } return(true); }
public bool termEqual(object term) { term = YP.getValue(term); if (term is Functor) { Functor termFunctor = (Functor)term; if (_name.Equals(termFunctor._name) && _args.Length == termFunctor._args.Length) { for (int i = 0; i < _args.Length; ++i) { if (!YP.termEqual(_args[i], termFunctor._args[i])) { return(false); } } return(true); } } return(false); }
/// <summary> /// Return a ListPair version of array, where repeated elements /// (according to YP.termEqual) are removed. /// </summary> /// <param name="array"></param> /// <returns></returns> public static object makeWithoutRepeatedTerms(object[] array) { if (array.Length <= 0) { return(Atom.NIL); } // Start from the end. object previousTerm = array[array.Length - 1]; object result = new ListPair(previousTerm, Atom.NIL); for (int i = array.Length - 2; i >= 0; --i) { object term = array[i]; if (YP.termEqual(term, previousTerm)) { continue; } result = new ListPair(term, result); previousTerm = term; } return(result); }
public bool lessThan(Functor functor) { // Do the equal check first since it is faster. if (!_name.Equals(functor._name)) { return(_name.lessThan(functor._name)); } if (_args.Length != functor._args.Length) { return(_args.Length < functor._args.Length); } for (int i = 0; i < _args.Length; ++i) { if (!YP.termEqual(_args[i], functor._args[i])) { return(YP.termLessThan(_args[i], functor._args[i])); } } return(false); }