Returns a sequence of values consecutively generated by a generator function.
Declaration Syntax
C# | Visual Basic | Visual C++ |
public static IEnumerable<TResult> Generate<TResult>( TResult initial, Func<TResult, TResult> generator )
Public Shared Function Generate(Of TResult) ( _ initial As TResult, _ generator As Func(Of TResult, TResult) _ ) As IEnumerable(Of TResult)
public: generic<typename TResult> static IEnumerable<TResult>^ Generate( TResult initial, Func<TResult, TResult>^ generator )
Generic Template Parameters
- TResult
- Type of elements to generate.
Parameters
- initial (TResult)
- Value of first element in sequence
- generator (Func<(Of <(<'TResult, TResult>)>)>)
- Generator function which takes the previous series element and uses it to generate the next element.
Return Value
[Missing <returns> documentation for "M:MoreLinq.MoreEnumerable.Generate``1(``0,System.Func{``0,``0})"]
Remarks
This function defers element generation until needed and streams the results.
Examples
Copy | |
---|---|
IEnumerable<int> result = Sequence.Generate(2, n => n * n).Take(5); |
Assembly: MoreLinq (Module: MoreLinq.dll) Version: 1.0.16006.0 (1.0.16006.1845)