|
|
@@ -2762,6 +2762,8 @@ namespace InABox.Core
|
|
|
return newArr;
|
|
|
}
|
|
|
|
|
|
+ #region Generators
|
|
|
+
|
|
|
public static IEnumerable<T> AnyOr<T>(this IEnumerable<T> enumerable, IEnumerable<T> or)
|
|
|
{
|
|
|
var any = false;
|
|
|
@@ -2788,6 +2790,30 @@ namespace InABox.Core
|
|
|
yield return fnc();
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Range from <paramref name="from"/> to <paramref name="to"/>.
|
|
|
+ /// </summary>
|
|
|
+ public static IEnumerable<T> Range<T>(T from, T to, Func<T, T> step, bool inclusive = false)
|
|
|
+ where T : IComparable<T>
|
|
|
+ {
|
|
|
+ if (inclusive)
|
|
|
+ {
|
|
|
+ for(; from.CompareTo(to) <= 0; from = step(from))
|
|
|
+ {
|
|
|
+ yield return from;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ for(; from.CompareTo(to) < 0; from = step(from))
|
|
|
+ {
|
|
|
+ yield return from;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
public static (List<T>, List<T>) PartitionToList<T>(this IEnumerable<T> enumerable, Func<T, bool> predicate)
|
|
|
{
|
|
|
var trueResult = new List<T>();
|