2021aoc/Extension.cs

12 lines
430 B
C#

namespace AoC2021;
public static class Extension {
public static void ForEachIndex<T>(this IEnumerable<T> enumerable, Action<T, int> action) {
var l = enumerable.ToList();
Enumerable.Range(0, l.Count).ToList().ForEach(i => action.Invoke(l[i], i));
}
public static void ForEachAsList<T>(this IEnumerable<T> enumerable, Action<T> action) {
enumerable.ToList().ForEach(action);
}
}