Class EnumerableExtensionMethods
- Namespace
- SodaFlow.Functional
- Assembly
- SodaFlow.Functional.dll
The operations on an ordinary sequence which answer with a Maybe<T> rather than with a default value or an exception.
[PublicAPI]
public static class EnumerableExtensionMethods
- Inheritance
-
EnumerableExtensionMethods
- Inherited Members
Remarks
Each of these mirrors a LINQ operator whose OrDefault version cannot
say if it found anything. FirstOrDefault over a sequence of
int gives zero for an empty sequence, and for one whose
first element is zero. An answer with a Maybe<T> keeps the
two apart.
A null sequence counts as empty in each member here, and
this matches the behavior of MaybeExtensionMethods.
Methods
- AggregateOrNone<T>(IEnumerable<T>?, Func<T, T, T>)
Combines the elements of a sequence with a function, if it has any.
- Choose<T, TResult>(IEnumerable<T>?, Func<T, Maybe<TResult>>)
Applies a function which can give no value to each element of a sequence, and gives the results with a value.
- Choose<T, TResult>(IEnumerable<T>?, Func<T, int, Maybe<TResult>>)
Applies a function which can give no value to each element of a sequence along with its index, and gives the results with a value.
- ElementAtOrNone<T>(IEnumerable<T>?, int)
Returns the element at a given position in a sequence, if there is one there.
- FirstOrNone<T>(IEnumerable<T>?)
Returns the first element of a sequence, if it has one.
- FirstOrNone<T>(IEnumerable<T>?, Func<T, bool>)
Returns the first element of a sequence which satisfies a predicate, if there is one.
- LastOrNone<T>(IEnumerable<T>?)
Returns the last element of a sequence, if it has one.
- LastOrNone<T>(IEnumerable<T>?, Func<T, bool>)
Returns the last element of a sequence which satisfies a predicate, if there is one.
- MaxOrNone<T>(IEnumerable<T>?)
Returns the largest element of a sequence, if it has any.
- MaxOrNone<T>(IEnumerable<T>?, IComparer<T>?)
Returns the largest element of a sequence by the given comparer, if it has any.
- MaxOrNone<T, TResult>(IEnumerable<T>?, Func<T, TResult>)
Returns the largest value produced from a sequence, if it has any elements.
- MinOrNone<T>(IEnumerable<T>?)
Returns the smallest element of a sequence, if it has any.
- MinOrNone<T>(IEnumerable<T>?, IComparer<T>?)
Returns the smallest element of a sequence by the given comparer, if it has any.
- MinOrNone<T, TResult>(IEnumerable<T>?, Func<T, TResult>)
Returns the smallest value produced from a sequence, if it has any elements.
- SingleOrNone<T>(IEnumerable<T>?)
Returns the only element of a sequence, if it has one.
- SingleOrNone<T>(IEnumerable<T>?, Func<T, bool>)
Returns the only element of a sequence which satisfies a predicate, if there is one.