public static PlTerm PlList(IEnumerable <PlTerm> terms) { var list = new PlTerm("[]"); foreach (var term in terms) { list.Add(term); } return(list); }
public void List_Add_term_2() { var t = new PlTerm("[x,y]"); var l = new PlTerm("[a,b]"); Assert.AreEqual("[x,y]", t.ToString(), "t != [x,y]"); Assert.IsTrue(l.Add(t), "Add returns false"); Assert.AreEqual(3, list_length(l), "list_length l"); // NOTE list T is one term so Assert.AreEqual("[a,b,[x,y]]", l.ToString(), "string comp"); }
public void List_Add_term() { var t = new PlTerm("c"); var l = new PlTerm("[a,b]"); Assert.AreEqual("c", t.ToString(), "t != c"); Assert.AreEqual("[a,b]", l.ToString(), "l != [a,b]"); Assert.IsTrue(l.Add(t), "Add returns false"); Assert.AreEqual(3, list_length(l), "list_length l"); Assert.AreEqual("[a,b,c]", l.ToString(), "string comp"); }
public static bool modify_list(PlTerm listIn, PlTerm listOut) { using (new PlFrame()) { var list = new PlTerm("[]"); Assert.IsTrue(listIn.IsList); foreach (PlTerm elem in PlTerm.PlTail(listIn)) { list.Add(new PlTerm(elem.ToString() + elem.ToString())); } listOut.Unify(list); } return(true); }