Click or drag to resize

MoreEnumerableUnfoldTState, T, TResult Method

Returns a sequence generated by applying a state to the generator function, and from its result, determines if the sequence should have a next element, its value, and the next state in the recursive call.

Namespace:  MoreLinq
Assembly:  MoreLinq (in MoreLinq.dll) Version: 2.7.0
Syntax
public static IEnumerable<TResult> Unfold<TState, T, TResult>(
	TState state,
	Func<TState, T> generator,
	Func<T, bool> predicate,
	Func<T, TState> stateSelector,
	Func<T, TResult> resultSelector
)

Parameters

state
Type: TState
The initial state.
generator
Type: SystemFuncTState, T
Function that takes a state and computes the next state and the next element of the sequence.
predicate
Type: SystemFuncT, Boolean
Function to determine if the unfolding should continue based the result of the generator function.
stateSelector
Type: SystemFuncT, TState
Function to select the state from the output of the generator function.
resultSelector
Type: SystemFuncT, TResult
Function to select the result from the output of the generator function.

Type Parameters

TState
Type of state elements.
T
Type of the elements generated by the generator function.
TResult
The type of the elements of the result sequence.

Return Value

Type: IEnumerableTResult
A sequence containing the results generated by the resultSelector function.
Remarks
This operator uses deferred execution and streams its results.
See Also