Skip to content

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

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

[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>
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.

0 participants