diff --git a/Sanchime.Functional/Extensions/Either.cs b/Sanchime.Functional/Extensions/Either.cs index ee61f21..bbd27c0 100644 --- a/Sanchime.Functional/Extensions/Either.cs +++ b/Sanchime.Functional/Extensions/Either.cs @@ -64,4 +64,6 @@ public static class EitherExtension public static Either ForEach(this Either either, Action action) => either.Map(action.ToFunc()); + + } diff --git a/Sanchime.Functional/Extensions/IEnumerable.cs b/Sanchime.Functional/Extensions/IEnumerable.cs index c2ead6e..ccb30dc 100644 --- a/Sanchime.Functional/Extensions/IEnumerable.cs +++ b/Sanchime.Functional/Extensions/IEnumerable.cs @@ -108,6 +108,32 @@ public static class IEnumerableExtension public static IEnumerable Flatten(this IEnumerable> source) => source.SelectMany(x => x); + public static IEnumerable DropWhile(this IEnumerable source, Func predicate) + { + bool cleaned = true; + foreach (var item in source) + { + if (!cleaned && !predicate(item)) + { + yield return item; + cleaned = false; + } + } + } + + public static IEnumerable Append(this IEnumerable source, params T[] list) + => source.Concat(list); + + public static IEnumerable Prepend(this IEnumerable source, T value) + { + yield return value; + foreach (var item in source) + { + yield return item; + } + } + + private static IEnumerable List(params T[] list) => list.ToImmutableList();