[Repo Assist] feat: add map, filter, iter, exists, forall, toList, toArray to Queue and Deque#241
Conversation
… and Deque modules Adds commonly needed collection functions to Queue and Deque that were present in F# List but missing from these modules. Addresses part of #152 (Align Collection Module functions with FSharp.Collections). New functions for both Queue and Deque: - map : transform each element, returning the same collection type - filter : keep elements matching a predicate - iter : apply a side-effecting function to each element (FIFO order) - exists : test whether any element satisfies a predicate - forall : test whether all elements satisfy a predicate - toList : convert to list in FIFO order - toArray : convert to array in FIFO order All seven functions are O(n) and preserve FIFO element order. 21 new tests added (QueueTest and DequeTest), all passing. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… 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>
There was a problem hiding this comment.
Pull request overview
Adds FSharp.Collections-aligned collection helpers to Queue and Deque, expanding their module APIs with common traversal/transformation/conversion functions while preserving the collections’ logical ordering.
Changes:
- Added
toList,toArray,map,filter,iter,exists,foralltoQueueandDequeimplementations. - Exposed the new functions in the corresponding
.fsisignature files. - Added unit tests covering the new APIs (order preservation and basic semantics).
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
src/FSharpx.Collections/Queue.fs |
Implements the seven new Queue module functions. |
src/FSharpx.Collections/Queue.fsi |
Adds public signatures/docs for the new Queue functions (also includes spacing/formatting changes). |
src/FSharpx.Collections/Deque.fs |
Implements the seven new Deque module functions. |
src/FSharpx.Collections/Deque.fsi |
Adds public signatures/docs for the new Deque functions (also includes spacing/formatting changes). |
tests/FSharpx.Collections.Tests/QueueTest.fs |
Adds tests for new Queue APIs (FIFO order and basic behavior). |
tests/FSharpx.Collections.Tests/DequeTest.fs |
Adds tests for new Deque APIs (order and basic behavior). |
💡 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.
|
@copilot resolve the confilts too |
Agent-Logs-Url: https://github.com/fsprojects/FSharpx.Collections/sessions/5505841c-0090-46f8-9556-d78eba3c714b Co-authored-by: gdziadkiewicz <8547855+gdziadkiewicz@users.noreply.github.com>
|
@copilot resolve the merge conflicts in this pull request |
…t test Co-authored-by: gdziadkiewicz <8547855+gdziadkiewicz@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds common collection-style operations to Queue and Deque to better align with FSharp.Collections, including public signatures and accompanying tests.
Changes:
- Added
toList,toArray,map,filter,iter,exists, andforalltoQueueandDequemodules. - Updated
.fsifiles with the new public API surface and XML docs. - Added unit tests covering the new operations.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/FSharpx.Collections.Tests/QueueTest.fs | Adds tests for new Queue functions. |
| tests/FSharpx.Collections.Tests/DequeTest.fs | Adds tests for new Deque functions. |
| src/FSharpx.Collections/Queue.fsi | Exposes new Queue functions in the public signature. |
| src/FSharpx.Collections/Queue.fs | Implements new Queue functions. |
| src/FSharpx.Collections/Deque.fsi | Exposes new Deque functions in the public signature. |
| src/FSharpx.Collections/Deque.fs | Implements new Deque functions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…enumeration) order Agent-Logs-Url: https://github.com/fsprojects/FSharpx.Collections/sessions/5eadd029-f378-41de-ae25-5542f541bada Co-authored-by: gdziadkiewicz <8547855+gdziadkiewicz@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@copilot apply changes based on the comments in this thread |
Agent-Logs-Url: https://github.com/fsprojects/FSharpx.Collections/sessions/2df01a43-f11d-4d17-8335-41b66ae349ef Co-authored-by: gdziadkiewicz <8547855+gdziadkiewicz@users.noreply.github.com>
Done in 2f3fe67:
All 926 tests pass. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| test "forall returns true when all elements satisfy predicate" { | ||
| let q = Queue.ofSeq [ 2; 4; 6 ] | ||
| Expect.isTrue "forall" (Queue.forall (fun x -> x % 2 = 0) q) | ||
| } | ||
|
|
||
| test "forall returns false when some elements do not satisfy predicate" { | ||
| let q = Queue.ofSeq [ 2; 3; 6 ] | ||
| Expect.isFalse "forall false" (Queue.forall (fun x -> x % 2 = 0) q) | ||
| } ] |
There was a problem hiding this comment.
The new Queue.forall tests cover all-true and some-false inputs, but don’t cover the empty-queue behavior. Other collection tests in this repo typically assert forall on empty returns true; adding that case here would align behavior guarantees across collections.
There was a problem hiding this comment.
Added in 5d66835 — Queue.forall now has a test asserting it returns true for an empty queue.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…20260310-abe469ac1b3fa769
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Agent-Logs-Url: https://github.com/fsprojects/FSharpx.Collections/sessions/bb349dd2-2f46-45f5-88f9-0b306455ec7d Co-authored-by: gdziadkiewicz <8547855+gdziadkiewicz@users.noreply.github.com>
🤖 This PR was created by Repo Assist, an automated AI assistant.
Adds seven commonly used collection functions to the
QueueandDequemodules. Partially addresses #152 (Align Collection Module functions with FSharp.Collections).Changes
New functions (Queue and Deque)
map f qQueue/Dequefilter pred qiter f qexists pred qforall pred qtoList qtoArray qAll functions preserve FIFO element order. Signatures added to
.fsifiles. 21 new tests added.Implementation notes
Queue.mapdirectly maps over the internalfrontandrBacklists, preserving the queue structure without any rebuilding — very efficient.Queue.filterhandles the invariant thatfrontshould not be empty for a non-empty queue: if filtering removes allfrontelements,List.rev rBackbecomes the newfront.Deque.mapsimilarly maps directly over both internal lists.Deque.filteris simpler since Deque tolerates an emptyfront(it falls back torBack).existsandforallcan checkrBackin any order (order only matters foriter,toList,toArray).Test Status
All 731 tests pass (6 pre-existing
ptestskips unrelated to this PR):