Conversation
…289) - TaskSeq.chunkBySize: divides a task sequence into non-overlapping chunks of at most chunkSize elements. Uses a fixed-size array buffer (vs. ResizeArray) to avoid intermediate allocations and resizing. - TaskSeq.windowed: returns overlapping sliding windows of a fixed size. Uses a ring buffer internally so that only a single allocation (per window) is needed; no redundant element copies on each step. Both functions validate their size argument eagerly (before enumeration starts), raise ArgumentException for non-positive sizes, and are fully documented in the .fsi signature file. Also: - Update README.md to mark chunkBySize, windowed, pairwise, scan/scanAsync, reduce/reduceAsync, and unfold/unfoldAsync as implemented (these were merged in PRs #293, #296, #299, #300 respectively). - Update release-notes.txt for 0.5.0. - 171 new tests across TaskSeq.ChunkBySize.Tests.fs and TaskSeq.Windowed.Tests.fs. All 4021 existing tests continue to pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
11 tasks
dsyme
approved these changes
Mar 7, 2026
…3-3f5b2d6577426398
…3-3f5b2d6577426398
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This PR was created by Repo Assist, an automated AI assistant.
Summary
Adds two sequence-segmentation combinators that were explicitly requested (see #258 and the closing comment on #265) and are part of the
SeqAPI alignment tracked in #289.TaskSeq.chunkBySizeDivides a task sequence into non-overlapping chunks of at most
chunkSizeelements. The last chunk may be smaller if the source does not divide evenly.Performance: uses a fixed-size pre-allocated
'T[]buffer instead of aResizeArray, avoiding resize allocations. OneArray.copyper full chunk, oneArray.subfor the last partial chunk.TaskSeq.windowedReturns overlapping sliding windows of exactly
windowSizeconsecutive elements.Performance: maintains a ring buffer of size
windowSize— each new element is written in O(1) at the current position. When a full window is ready, twoArray.blitcalls copy it in source order to a fresh result array, giving a single allocation per window with no redundant element movement.Both functions:
ArgumentExceptionfor non-positive sizes — consistent withSeq.chunkBySize/Seq.windowed..fsisignature file.Other changes
chunkBySize,windowed,pairwise,scan/scanAsync,reduce/reduceAsync, andunfold/unfoldAsyncas implemented (these were merged in PRs [Repo Assist] feat/test: add TaskSeq.pairwise; expand distinctUntilChanged tests #293, [Repo Assist] feat: add TaskSeq.scan and TaskSeq.scanAsync (ref #289) #296, [Repo Assist] feat: add TaskSeq.reduce and TaskSeq.reduceAsync (ref #289) #299, [Repo Assist] feat: add TaskSeq.unfold and TaskSeq.unfoldAsync (ref #289) #300 but the README wasn't updated).release-notes.txt: updated for 0.5.0.Tests
TaskSeq.ChunkBySize.Tests.fsandTaskSeq.Windowed.Tests.fs— 171 new tests covering:TestEmptyVariants)TestImmTaskSeqvariants: order preservation, chunk/window sizes, remainder, exact-size, larger-than-sourcewindowed)Test Status
✅ Build: succeeded (0 warnings, 0 errors) — verified locally against .NET SDK 10.0.102
✅ Tests: 4,021 passed, 2 skipped, 0 failed (full suite)
✅ Formatting:
dotnet fantomas . --checkpassesCloses #258