[Repo Assist] feat: add map, filter, iter, exists, forall, toArray to DList#246
Draft
github-actions[bot] wants to merge 2 commits intomasterfrom
Draft
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>
22 tasks
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.