public int CompareTo(Array1 <T> other) => (Rest.Length == other.Rest.Length) ? ToEnumerable().Zip( other.ToEnumerable(), (a, b) => { if (a is IComparable comparable) { return(comparable.CompareTo(b)); } throw new Exception("Trying to compare Array1 based on non-comparable type " + typeof(T).ToString()); }).SkipWhile(c => c == 0).Take(1).Sum() // The SUM will get a 0 on full equality which is as you'd want : Rest.Length.CompareTo(other.Rest.Length);
public bool Equals(Array1 <T> obj) => (Rest.Length == obj.Rest.Length) && ToEnumerable().Zip(obj.ToEnumerable(), (a, b) => a.Equals(b)).All(x => x);