Skip to content

[Repo Assist] feat: add fold, map, filter, iter, exists, forall, toList, toArray, ofList, ofArray, choose to Heap module#252

Open
github-actions[bot] wants to merge 2 commits intomasterfrom
repo-assist/improve-heap-module-functions-2026-03-15-933c8db427a7585a
Open

[Repo Assist] feat: add fold, map, filter, iter, exists, forall, toList, toArray, ofList, ofArray, choose to Heap module#252
github-actions[bot] wants to merge 2 commits intomasterfrom
repo-assist/improve-heap-module-functions-2026-03-15-933c8db427a7585a

Conversation

@github-actions
Copy link
Contributor

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

Summary

Adds 11 missing collection-style functions to the Heap module, addressing the gap in #152 ("Align Collection Module functions with FSharp.Collections"):

Function Description
Heap.toList O(n) — returns elements as a sorted list
Heap.toArray O(n) — returns elements as a sorted array
Heap.ofList O(n log n) — builds a heap from a list
Heap.ofArray O(n log n) — builds a heap from an array
Heap.fold O(n) — folds over elements in sorted order
Heap.iter O(n) — iterates over elements in sorted order
Heap.exists O(n) — tests whether any element satisfies a predicate
Heap.forall O(n) — tests whether all elements satisfy a predicate
Heap.map O(n log n) — maps elements to a new heap, preserving sort direction
Heap.filter O(n log n) — filters elements to a new heap
Heap.choose O(n log n) — applies an option-returning function; keeps Some values

All functions are implemented as thin inline wrappers around the existing toSeq/ofSeq primitives. The sort direction (isDescending) is preserved automatically by map, filter, and choose.

Tests

18 new tests added to HeapTest.fs covering every new function including edge cases (empty heap, sort direction preservation, round-trips).

Test Status

✅ Build succeeded (0 errors, 25 warnings — all pre-existing)
dotnet test — 757 passed, 0 failed, 6 skipped (pre-existing skips)
✅ Fantomas formatting check passed

Closes part of #152

Generated by Repo Assist ·

To install this agentic workflow, run

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

…fList, ofArray, choose to Heap module

Add 11 missing collection-style functions to the Heap module, consistent
with FSharp.Collections patterns and addressing the gap identified in #152.

All functions are implemented as inline wrappers around toSeq/ofSeq, which
means:
- toList/toArray return elements in sorted order (ascending or descending)
- ofList/ofArray build a heap from a list/array
- fold/iter/exists/forall traverse elements in sorted order
- map/filter/choose return new heaps preserving the sort direction

18 new tests covering all added functions, all passing.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dsyme dsyme marked this pull request as ready for review March 16, 2026 13:45
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