public static IEnumerable <TResult> SelectMany <TResult>(this Range range, Func <int, Range> fun1, Func <int, int, TResult> fun2) { foreach (var s in range.AsEnumerable()) { var range2 = fun1(s); foreach (var t in range2.AsEnumerable()) { yield return(fun2(s, t)); } } }
public static IEnumerable <TResult> Select <TResult>(this Range range, Func <int, TResult> selector) { return(range.AsEnumerable().Select(selector)); }
public static IEnumerable <TResult> Cast <TResult>(this Range range) { return(range.AsEnumerable().Cast <TResult>()); }
public static IEnumerator <int> GetEnumerator(this Range range) { return(range.AsEnumerable().GetEnumerator()); }
public static void Add(this ICollection <int> collection, Range range) { collection.Add(range.AsEnumerable()); }
public static IEnumerable <int> ToArray(this Range range) => range.AsEnumerable().ToArray();
public static IEnumerable <TResult> SelectMany <TCollection, TResult>(this Range range, Func <int, IEnumerable <TCollection> > fun1, Func <int, TCollection, TResult> fun2) { return(Enumerable.SelectMany <int, TCollection, TResult>(range.AsEnumerable(), fun1, fun2)); }
public static IEnumerable <TResult> SelectMany <TResult>(this Range range, Func <int, IEnumerable <TResult> > fun) { return(range.AsEnumerable().SelectMany(fun)); }
public static IEnumerable <int> Where(this Range range, Func <int, bool> fun) { return(range.AsEnumerable().Where(fun)); }
public static IEnumerable <int> Select(this Range range, Func <int, int> fun) { return(range.AsEnumerable().Select(fun)); }
public static IEnumerable <int> Take(this Range range, int n) { return(range.AsEnumerable().Take(n)); }
/// <summary> /// Range GetEnumerator method, allows foreach over a range as long as the indices are not from the end /// </summary> /// <param name="range">Range to get the Enumerator for</param> /// <returns>An enumerator over the entire range</returns> /// <exception cref="ArgumentException">If any of the indices are marked as from the end</exception> public static IEnumerator <int> GetEnumerator(this Range range) => range.AsEnumerable().GetEnumerator();