public static ImList <T> Create(IEnumerable <T> values) { var valuesArray = values.ToArray(); ImList <T> list = Nil; for (int i = valuesArray.Length - 1; i >= 0; i--) { list = new ConsList(valuesArray[i], list); } return(list); }
public ConsList(T headUnsafe, ImList <T> tailUnsafe) { HeadUnsafe = headUnsafe; TailUnsafe = tailUnsafe; }
public static ImList <T> Cons(T head, ImList <T> tail) => new ConsList(head, tail);