Skip to content

Commit

Permalink
Elegance
Browse files Browse the repository at this point in the history
  • Loading branch information
louthy committed Aug 16, 2024
1 parent 7b7963f commit 81473c4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Samples/Streams/Folding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ public static class Folding
from x in example(1000).Iter().As()
select unit;

static StreamT<IO, int> naturals =>
Range(0, int.MaxValue).AsStream<IO>();

static StreamT<IO, Unit> example(int n) =>
from v in Range(0, n).AsStream<IO>()
.FoldUntil(0, (s, x) => s + x, (s, _) => s % 10 == 0)
from v in naturals.FoldUntil(0, (s, x) => s + x, (s, _) => s % 10 == 0)
from _ in writeLine(v.ToString())
where false
select unit;
Expand Down

0 comments on commit 81473c4

Please sign in to comment.