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)); }
private static string DumpList <T>(CatenableList <T> .C list) { if (CatenableList <T> .IsEmpty(list)) { return("\u2205"); } var result = new StringBuilder(); while (!CatenableList <T> .IsEmpty(list)) { result.Append(CatenableList <T> .Head(list)); list = CatenableList <T> .Tail(list); result.Append(", "); } result.Remove(result.Length - 2, 2); return(result.ToString()); }