I\'m interested if there is a way, in LINQ, to check if all numbers in a list are increasing monotonically?
Example
List l
Consider an implementation like the following, which enumerates the given IEnumerable only once. Enumerating can have side-effects, and callers typically expect a single pass-through if that's possible.
public static bool IsIncreasingMonotonically(
this IEnumerable _this)
where T : IComparable
{
using (var e = _this.GetEnumerator())
{
if (!e.MoveNext())
return true;
T prev = e.Current;
while (e.MoveNext())
{
if (prev.CompareTo(e.Current) > 0)
return false;
prev = e.Current;
}
return true;
}
}