public IEnumerable <bool> unify(object arg) { arg = YP.getValue(arg); if (arg is Variable) { return(((Variable)arg).unify(this)); } else { return(Equals(arg) ? YP.succeed() : YP.fail()); } }
/// <summary> /// If Obj is an Atom unify its _module with Module. If the Atom's _module is null, use Atom.NIL. /// </summary> /// <param name="Atom"></param> /// <param name="Module"></param> /// <returns></returns> public static IEnumerable <bool> module(object Obj, object Module) { Obj = YP.getValue(Obj); if (Obj is Atom) { if (((Atom)Obj)._module == null) { return(YP.unify(Module, Atom.NIL)); } else { return(YP.unify(Module, ((Atom)Obj)._module)); } } return(YP.fail()); }
/// <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()); } }