/// <summary> /// If arg is another Functor, then succeed (yield once) if this and arg have the /// same name and all functor args unify, otherwise fail (don't yield). /// If arg is a Variable, then call its unify to unify with this. /// Otherwise fail (don't yield). /// </summary> /// <param name="arg"></param> /// <returns></returns> public IEnumerable <bool> unify(object arg) { arg = YP.getValue(arg); if (arg is Functor) { Functor argFunctor = (Functor)arg; if (_name.Equals(argFunctor._name)) { return(YP.unifyArrays(_args, argFunctor._args)); } else { return(YP.fail()); } } else if (arg is Variable) { return(((Variable)arg).unify(this)); } else { return(YP.fail()); } }
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; }