Skip to content

[Repo Assist] feat: add map, filter, iter, exists, forall, toArray to DList#246

Open
github-actions[bot] wants to merge 2 commits intomasterfrom
repo-assist/improve-dlist-map-filter-iter-152-a95e6e8df17c5a51
Open

[Repo Assist] feat: add map, filter, iter, exists, forall, toArray to DList#246
github-actions[bot] wants to merge 2 commits intomasterfrom
repo-assist/improve-dlist-map-filter-iter-152-a95e6e8df17c5a51

Conversation

@github-actions
Copy link
Contributor

🤖 This PR was created by Repo Assist, an automated AI assistant.

Summary

Adds six new module-level functions to DList, mirroring the functions added to Queue and Deque in #241, and further addressing #152 (aligning collection module functions).

Function Description
DList.map Transforms all elements using a mapping function
DList.filter Retains only elements matching a predicate
DList.iter Applies an action to each element in order
DList.exists Returns true if any element satisfies the predicate (short-circuits)
DList.forall Returns true if all elements satisfy the predicate (short-circuits)
DList.toArray Returns elements as an array

Implementation Notes

  • map and filter are implemented via foldBack, building a new DList directly. This preserves the length invariant (the int length field tracked in the DList type) without a separate counting pass.
  • iter, exists, forall, and toArray delegate to the IEnumerable<'T> implementation. This gives correct short-circuit behaviour for exists/forall at no extra cost.

Tests

Adds 21 new tests:

  • 14 unit tests covering normal cases, empty-list edge cases, and boundary conditions for all six functions.
  • 7 property-based tests using testPropertyWithConfig generators (matching those used elsewhere in DListTest.fs) that verify results match the equivalent List/Array standard-library functions.

Test Status

Passed!  - Failed: 0, Passed: 727, Skipped: 6, Total: 733

All tests pass. Code formatted with Fantomas before commit.

Generated by Repo Assist ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@346204513ecfa08b81566450d7d599556807389f

… 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>
@gdziadkiewicz
Copy link
Collaborator

/repo-assist resolve conflict

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, and DList.toArray to the DList module (with corresponding .fsi signatures).
  • Extended DListTest.fs with new unit tests and property-based tests to validate behavior against standard List/Array equivalents.

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 dsyme marked this pull request as ready for review March 16, 2026 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants