import sys # Hack sys.path for the examples. sys.path.append("../..") from YP import * from Variable import * from ListPair import *
def makeList(First, Second, List): list1 = ListPair(Second, Atom.NIL) result = ListPair(First, list1) for l1 in YP.unify(List, result): yield False
def main(): print("Unify two lists:") Second = Variable() for l1 in makeList("x", Second, ListPair("x", ListPair("y", Atom.NIL))): print("The second element is " + Second.getValue())
|
using System; using System.Collections.Generic; using YieldProlog; class Tutorial3 { static IEnumerable<bool> makeList (object First, object Second, object List) { ListPair list1 = new ListPair(Second, Atom.NIL); ListPair result = new ListPair(First, list1); foreach (bool l1 in YP.unify(List, result)) yield return false; }
static void Main(string[] args) { Console.WriteLine("Unify two lists:"); Variable Second = new Variable(); foreach (bool l1 in makeList("x", Second, new ListPair("x", new ListPair("y", Atom.NIL)))) Console.WriteLine("The second element is " + Second.getValue()); } }
|