更新IEnumerable扩展
This commit is contained in:
parent
87d0931986
commit
3f61a327c1
|
@ -93,11 +93,20 @@ public static class IEnumerableExtension
|
|||
public static IEnumerable<Unit> ForEach<T>(this IEnumerable<T> source, Action<T> action)
|
||||
=> source.Map(action.ToFunc()).ToImmutableList();
|
||||
|
||||
public static IEnumerable<R> Bind<T, R>(this IEnumerable<T> source, Func<T, IEnumerable<R>> func)
|
||||
=> source.SelectMany(func);
|
||||
public static IEnumerable<R> Bind<T, R>(this IEnumerable<T> source, Func<T, IEnumerable<R>> binding)
|
||||
=> source.SelectMany(binding);
|
||||
|
||||
public static IEnumerable<R> Bind<T, R>(this IEnumerable<T> source, Func<T, Option<R>> func)
|
||||
=> source.Bind(t => func(t).AsEnumerable());
|
||||
public static IEnumerable<R> Bind<T, R>(this IEnumerable<T> source, Func<T, Option<R>> binding)
|
||||
=> source.Bind(val => binding(val).AsEnumerable());
|
||||
|
||||
/// <summary>
|
||||
/// 将二级序列平展
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<T> Flatten<T>(this IEnumerable<IEnumerable<T>> source)
|
||||
=> source.SelectMany(x => x);
|
||||
|
||||
|
||||
private static IEnumerable<T> List<T>(T t)
|
||||
|
|
Loading…
Reference in New Issue