def brother(Person, Brother): for l1 in generalUnify(Person, "Hillary"): for l2 in generalUnify(Brother, "Tony"): yield False for l2 in generalUnify(Brother, "Hugh"): yield False for l1 in generalUnify(Person, "Bill"): for l2 in generalUnify(Brother, "Roger"): yield False
def parent(Person, Parent): for l1 in generalUnify(Person, "Chelsea"): for l2 in generalUnify(Parent, "Hillary"): yield False for l1 in generalUnify(Person, "Chelsea"): for l2 in generalUnify(Parent, "Bill"): yield False
def uncle(Person, Uncle): Parent = UnifyingVariable() for l1 in parent(Person, Parent): for l2 in brother(Parent, Uncle): yield False
def main(): print("Joining functions:") Person = UnifyingVariable() Uncle = UnifyingVariable() for l1 in uncle(Person, Uncle): print(Person._value + " has uncle " + Uncle._value + ".")
|
using System; using System.Collections.Generic; class Tutorial1 { static IEnumerable<bool> brother (object Person, object Brother) { foreach (bool l1 in generalUnify(Person, "Hillary")) { foreach (bool l2 in generalUnify(Brother, "Tony")) yield return false; foreach (bool l2 in generalUnify(Brother, "Hugh")) yield return false; } foreach (bool l1 in generalUnify(Person, "Bill")) { foreach (bool l2 in generalUnify(Brother, "Roger")) yield return false; } }
static IEnumerable<bool> parent (object Person, object Parent) { foreach (bool l1 in generalUnify(Person, "Chelsea")) { foreach (bool l2 in generalUnify(Parent, "Hillary")) yield return false; } foreach (bool l1 in generalUnify(Person, "Chelsea")) { foreach (bool l2 in generalUnify(Parent, "Bill")) yield return false; } }
static IEnumerable<bool> uncle (object Person, object Uncle) { UnifyingVariable Parent = new UnifyingVariable(); foreach (bool l1 in parent(Person, Parent)) { foreach (bool l2 in brother(Parent, Uncle)) yield return false; } }
static void Main(string[] args) { Console.WriteLine("Joining functions:"); UnifyingVariable Person = new UnifyingVariable(); UnifyingVariable Uncle = new UnifyingVariable(); foreach (bool l1 in uncle(Person, Uncle)) Console.WriteLine(Person._value + " has uncle " + Uncle._value + "."); } }
|