Consider adding an operator that remove items from the tail end of a sequence while a given predicate returns true. The proposed name and signature would be:
public static IEnumerable<T> SkipLastWhile<T>(this IEnumerable<T> source, Func<T, bool> predicate)
Example:
var xs = new[]
{
1, 2,
0, 0, // will be preserved (not in tail position)
3, 4,
0, 0, // will be removed
};
var result = xs.SkipLastWhile(x => x is 0);
Console.WriteLine(result.ToDelimitedString(", "));
Consider adding an operator that remove items from the tail end of a sequence while a given predicate returns true. The proposed name and signature would be:
Example:
Output: