[Repo Assist] feat: add map, filter, iter, exists, forall, toArray to DList#246
Open
github-actions[bot] wants to merge 2 commits intomasterfrom
Open
Conversation
… tests Adds six new module-level functions to DList, mirroring the functions added to Queue and Deque in #241, and further addressing #152. - DList.map: transforms all elements using a function - DList.filter: retains elements matching a predicate - DList.iter: applies an action to each element in order - DList.exists: short-circuit check if any element matches - DList.forall: short-circuit check if all elements match - DList.toArray: returns elements as an array map and filter are implemented via foldBack so they build a DList directly (preserving the length invariant). iter/exists/forall/toArray delegate to the IEnumerable<'T> implementation for correct short-circuit behaviour. Also adds 21 new tests: 14 unit tests and 7 property-based tests that verify results match standard List/Array equivalents. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced Mar 13, 2026
Collaborator
|
/repo-assist resolve conflict |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a set of common collection-style module functions to DList, aligning it with the APIs previously added for Queue/Deque and continuing the work from #241 / #152 to standardize collection module functionality across the codebase.
Changes:
- Added
DList.map,DList.filter,DList.iter,DList.exists,DList.forall, andDList.toArrayto theDListmodule (with corresponding.fsisignatures). - Extended
DListTest.fswith new unit tests and property-based tests to validate behavior against standardList/Arrayequivalents.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/FSharpx.Collections.Tests/DListTest.fs | Adds unit + property tests covering the six new DList module functions. |
| src/FSharpx.Collections/DList.fsi | Exposes the new DList module functions in the public signature. |
| src/FSharpx.Collections/DList.fs | Implements the new DList module functions (map, filter via foldBack; others via Seq). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
dsyme
approved these changes
Mar 17, 2026
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 six new module-level functions to
DList, mirroring the functions added toQueueandDequein #241, and further addressing #152 (aligning collection module functions).DList.mapDList.filterDList.iterDList.existstrueif any element satisfies the predicate (short-circuits)DList.foralltrueif all elements satisfy the predicate (short-circuits)DList.toArrayImplementation Notes
mapandfilterare implemented viafoldBack, building a newDListdirectly. This preserves the length invariant (theintlength field tracked in theDListtype) without a separate counting pass.iter,exists,forall, andtoArraydelegate to theIEnumerable<'T>implementation. This gives correct short-circuit behaviour forexists/forallat no extra cost.Tests
Adds 21 new tests:
testPropertyWithConfiggenerators (matching those used elsewhere inDListTest.fs) that verify results match the equivalentList/Arraystandard-library functions.Test Status
All tests pass. Code formatted with Fantomas before commit.