/// If arg is another Functor2, 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). public IEnumerable <bool> unify(object arg) { arg = YP.getValue(arg); if (arg is Functor2) { Functor2 argFunctor = (Functor2)arg; if (_name.Equals(argFunctor._name)) { foreach (bool l1 in YP.unify(_arg1, argFunctor._arg1)) { foreach (bool l2 in YP.unify(_arg2, argFunctor._arg2)) { yield return(false); } } } } else if (arg is Variable) { foreach (bool l1 in ((Variable)arg).unify(this)) { yield return(false); } } }
/// <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()); } }