Applies a function to each element of the source sequence and returns a new sequence of result elements for source elements where the function returns a couple (2-tuple) having a true as its first element and result as the second.
Namespace: MoreLinq.ExtensionsMoreLinq (in MoreLinq.dll) Version: 3.0.0
Syntaxpublic static IEnumerable<TResult> Choose<T, TResult>( this IEnumerable<T> source, Func<T, (bool IsSome, TResult , )> chooser )
<ExtensionAttribute> Public Shared Function Choose(Of T, TResult) ( source As IEnumerable(Of T), chooser As Func(Of T, (IsSome As Boolean, As TResult, )) ) As IEnumerable(Of TResult)
public: [ExtensionAttribute] generic<typename T, typename TResult> static IEnumerable<TResult>^ Choose( IEnumerable<T>^ source, Func<T, ValueTuple<bool, TResult>>^ chooser )
[<ExtensionAttribute>] static member Choose : source : IEnumerable<'T> * chooser : Func<'T, ValueTuple<bool, 'TResult>> -> IEnumerable<'TResult>Parameters
Type:
IEnumerableTResultA sequence
TResultelements.
Usage NoteIn Visual Basic and C#, you can call this method as an instance method on any object of type
IEnumerableT. When you use instance method syntax to call this method, omit the first parameter. For more information, see
Extension Methods (Visual Basic)or
Extension Methods (C# Programming Guide).
RemarksThis method uses deferred execution semantics and streams its results.
Examplesvar str = "O,l,2,3,4,S,6,7,B,9"; var xs = str.Split(',').Choose(s => (int.TryParse(s, out var n), n));
The
xsvariable will be a sequence of the integers 2, 3, 4, 6, 7 and 9.
See AlsoRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4