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)); }
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 EmptyTailTest() { var list = CatenableList <string> .Empty; AssertThrows <ArgumentNullException>(() => CatenableList <string> .Tail(list)); }