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)); }
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()); }
public void EmptyHeadTest() { var list = CatenableList <string> .Empty; AssertThrows <ArgumentNullException>(() => CatenableList <string> .Head(list)); }