static void Main(string[] args) { Console.WriteLine("Yield Prolog Shell. Enter ctrl-Z to exit."); while (true) { Console.Write("?- "); string goalString = Console.ReadLine(); if (goalString == null) { break; } if (goalString == "") { Console.WriteLine("Enter ctrl-Z to exit."); continue; } Variable Goal = new Variable(); Variable VariableList = new Variable(); foreach (bool l1 in parseGoal(goalString, Goal, VariableList)) { try { bool gotMatch = false; foreach (bool l2 in YP.getIterator(Goal, null)) { gotMatch = true; if (YP.getValue(VariableList) != Atom.NIL) { // We are showing values, so allow the user to enter ";" to display the next match. writeValues(VariableList); if (!Console.ReadLine().StartsWith(";")) { break; } } } if (gotMatch) { if (YP.getValue(VariableList) == Atom.NIL) { // We didn't show any values. So just write true after matching (one or more times). Console.WriteLine("true"); } } else { Console.WriteLine("fail"); } } catch (PrologException exception) { Console.WriteLine(exception._term.ToString()); } } } }
public static IEnumerable <bool> uncle (object Person, object Uncle) { { Variable Goal = new Variable(); Variable Parent = new Variable(); foreach (bool l2 in YP.unify (Goal, new Functor2 (Atom.a("parent", Atom.a("")), Person, Parent))) { foreach (bool l3 in YP.getIterator (Goal, getDeclaringClass())) { foreach (bool l4 in YP.matchDynamic (Atom.a("brother"), new object[] { Parent, Uncle })) { yield return(false); } } } } }