Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚧 Add simpler Unfold overload #1015

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
Update with a more involved example
atifaziz committed Oct 15, 2023
commit a2a9721efa8249cce12e6d57925bf4865b265e17
10 changes: 7 additions & 3 deletions MoreLinq/Unfold.cs
Original file line number Diff line number Diff line change
@@ -42,9 +42,13 @@ static partial class MoreEnumerable
/// This operator uses deferred execution and streams its results.
/// </remarks>
/// <example>
/// <code><![CDATA[ var result = MoreEnumerable.Unfold(1, s => s <= 100 ? (true, s * 2, s) :
/// default); ]]></code>
/// The <c>result</c> will be a sequence that will yield <c>{ 1, 2, 4, 8, 16, 32, 64 }</c>.
/// <code><![CDATA[
/// var fibonacciNumbersLowerThan100 =
/// MoreEnumerable.Unfold((Curr: 0, Next: 1),
/// s => s.Curr < 100 ? (true, (s.Next, s.Curr + s.Next), s.Curr) : default);
/// ]]></code>
/// The <c>result</c> will be a sequence that will yield
/// <c>{ 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 }</c>.
/// </example>

public static IEnumerable<TResult> Unfold<TState, TResult>(