Commit 2194542
Add AsyncSeq.windowed for sliding window over async sequences (#241)
Adds AsyncSeq.windowed : int -> AsyncSeq<'T> -> AsyncSeq<'T[]>
This is a sliding-window combinator analogous to Seq.windowed and
Seq.pairwise (which is a special case with windowSize=2). Each window
is yielded as an immutable array snapshot; the window slides one
element at a time.
Implementation uses a Queue<'T> of capacity windowSize to maintain the
current window with O(1) enqueue/dequeue per element.
Includes 7 tests covering: empty source, source shorter than window,
exact-size source, sliding windows, size-1, size-2, and ArgumentException
for windowSize < 1.
All 201 tests pass.
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Don Syme <[email protected]>1 parent 29d1c0c commit 2194542
3 files changed
Lines changed: 63 additions & 0 deletions
File tree
- src/FSharp.Control.AsyncSeq
- tests/FSharp.Control.AsyncSeq.Tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1087 | 1087 | | |
1088 | 1088 | | |
1089 | 1089 | | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
1090 | 1105 | | |
1091 | 1106 | | |
1092 | 1107 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
198 | 198 | | |
199 | 199 | | |
200 | 200 | | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
201 | 209 | | |
202 | 210 | | |
203 | 211 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2599 | 2599 | | |
2600 | 2600 | | |
2601 | 2601 | | |
| 2602 | + | |
| 2603 | + | |
| 2604 | + | |
| 2605 | + | |
| 2606 | + | |
| 2607 | + | |
| 2608 | + | |
| 2609 | + | |
| 2610 | + | |
| 2611 | + | |
| 2612 | + | |
| 2613 | + | |
| 2614 | + | |
| 2615 | + | |
| 2616 | + | |
| 2617 | + | |
| 2618 | + | |
| 2619 | + | |
| 2620 | + | |
| 2621 | + | |
| 2622 | + | |
| 2623 | + | |
| 2624 | + | |
| 2625 | + | |
| 2626 | + | |
| 2627 | + | |
| 2628 | + | |
| 2629 | + | |
| 2630 | + | |
| 2631 | + | |
| 2632 | + | |
| 2633 | + | |
| 2634 | + | |
| 2635 | + | |
| 2636 | + | |
| 2637 | + | |
| 2638 | + | |
| 2639 | + | |
| 2640 | + | |
| 2641 | + | |
2602 | 2642 | | |
2603 | 2643 | | |
2604 | 2644 | | |
| |||
0 commit comments