From 3f61a327c1a591f1e3b32b542a921762f5ffb15c Mon Sep 17 00:00:00 2001 From: Sanchime Date: Thu, 12 May 2022 22:27:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0IEnumerable=E6=89=A9=E5=B1=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sanchime.Functional/Extensions/IEnumerable.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Sanchime.Functional/Extensions/IEnumerable.cs b/Sanchime.Functional/Extensions/IEnumerable.cs index ef5e4b7..f60e8a8 100644 --- a/Sanchime.Functional/Extensions/IEnumerable.cs +++ b/Sanchime.Functional/Extensions/IEnumerable.cs @@ -93,11 +93,20 @@ public static class IEnumerableExtension public static IEnumerable ForEach(this IEnumerable source, Action action) => source.Map(action.ToFunc()).ToImmutableList(); - public static IEnumerable Bind(this IEnumerable source, Func> func) - => source.SelectMany(func); + public static IEnumerable Bind(this IEnumerable source, Func> binding) + => source.SelectMany(binding); - public static IEnumerable Bind(this IEnumerable source, Func> func) - => source.Bind(t => func(t).AsEnumerable()); + public static IEnumerable Bind(this IEnumerable source, Func> binding) + => source.Bind(val => binding(val).AsEnumerable()); + + /// + /// 将二级序列平展 + /// + /// + /// + /// + public static IEnumerable Flatten(this IEnumerable> source) + => source.SelectMany(x => x); private static IEnumerable List(T t)