添加Append方法
This commit is contained in:
parent
432cdf0045
commit
e8a5dd982d
|
@ -64,4 +64,6 @@ public static class EitherExtension
|
|||
|
||||
public static Either<L, Unit> ForEach<L, R>(this Either<L, R> either, Action<R> action)
|
||||
=> either.Map(action.ToFunc());
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -108,6 +108,32 @@ public static class IEnumerableExtension
|
|||
public static IEnumerable<T> Flatten<T>(this IEnumerable<IEnumerable<T>> source)
|
||||
=> source.SelectMany(x => x);
|
||||
|
||||
public static IEnumerable<T> DropWhile<T>(this IEnumerable<T> source, Func<T, bool> predicate)
|
||||
{
|
||||
bool cleaned = true;
|
||||
foreach (var item in source)
|
||||
{
|
||||
if (!cleaned && !predicate(item))
|
||||
{
|
||||
yield return item;
|
||||
cleaned = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static IEnumerable<T> Append<T>(this IEnumerable<T> source, params T[] list)
|
||||
=> source.Concat(list);
|
||||
|
||||
public static IEnumerable<T> Prepend<T>(this IEnumerable<T> source, T value)
|
||||
{
|
||||
yield return value;
|
||||
foreach (var item in source)
|
||||
{
|
||||
yield return item;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static IEnumerable<T> List<T>(params T[] list)
|
||||
=> list.ToImmutableList();
|
||||
|
|
Loading…
Reference in New Issue