public void TailTest() { var list0 = CatenableList <string> .Empty; var list1 = CatenableList <string> .Cons("Rest", list0); var list2 = CatenableList <string> .Cons("Head", list1); Assert.AreSame(list1, CatenableList <string> .Tail(list2)); }
public void HeadTest() { const string head = "Head"; var list0 = CatenableList <string> .Empty; var list1 = CatenableList <string> .Cons("Rest", list0); var list2 = CatenableList <string> .Cons(head, list1); Assert.AreSame(head, CatenableList <string> .Head(list2)); }
public void IsEmptyTest() { var list = CatenableList <string> .Empty; Assert.IsTrue(CatenableList <string> .IsEmpty(list)); Assert.AreEqual("\u2205", DumpList(list)); list = CatenableList <string> .Cons("A", list); Assert.IsFalse(CatenableList <string> .IsEmpty(list)); Assert.AreEqual("A", DumpList(list)); }
public void ConsTest() { var list1 = "a b c".Split().Aggregate(CatenableList <string> .Empty, (current, word) => CatenableList <string> .Cons(word, current)); Assert.AreEqual("c, b, a", DumpList(list1)); }
public void Cat3Test() { var list1 = "a b c".Split().Aggregate(CatenableList <string> .Empty, (current, word) => CatenableList <string> .Cons(word, current)); var list2 = "x y z".Split().Aggregate(CatenableList <string> .Empty, (current, word) => CatenableList <string> .Cons(word, current)); var list3 = CatenableList <string> .Cat(list1, list2); Assert.AreEqual("c, b, a, z, y, x", DumpList(list3)); }
public void Cat2Test() { var list2 = "x y z".Split().Aggregate(CatenableList <string> .Empty, (current, word) => CatenableList <string> .Cons(word, current)); var list3 = CatenableList <string> .Cat(CatenableList <string> .Empty, list2); Assert.AreSame(list2, list3); }
public void Cat1Test() { var list1 = "a b c".Split().Aggregate(CatenableList <string> .Empty, (current, word) => CatenableList <string> .Cons(word, current)); var list3 = CatenableList <string> .Cat(list1, CatenableList <string> .Empty); Assert.AreSame(list1, list3); }