[Repo Assist] feat: add fold, foldBack, find, tryFind, filter, choose, partition, scan, indexed, unzip, pairwise, groupBy, max, min to NonEmpt [Content truncated due to length]#259
Draft
github-actions[bot] wants to merge 2 commits intomasterfrom
Draft
Conversation
…can, indexed, unzip, pairwise, groupBy, max, min to NonEmptyList (addresses #174) Add 14 missing standard List-equivalent functions to the NonEmptyList module: - fold/foldBack: thread accumulator through the list - find/tryFind: search for elements by predicate - filter/choose: return plain 'T list (result can be empty) - partition: split into two plain lists by predicate - scan: return NonEmptyList<'State> (always non-empty) - indexed: return NonEmptyList<int * 'T> - unzip: split NonEmptyList<'T1 * 'T2> into two NonEmptyLists - pairwise: return ('T * 'T) list (may be empty for singleton) - groupBy: return NonEmptyList<'Key * NonEmptyList<'T>> - max/min: safe since list is always non-empty Functions that preserve non-emptiness return NonEmptyList. Functions that may produce empty results return plain 'T list. Add 16 property-based tests covering all new functions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Closes #174
Summary
Adds 14 missing standard
List-equivalent functions to theNonEmptyListmodule, addressing the long-standing gap identified in #174.Functions Added
fold'StateList.foldfoldBack'StateList.foldBackfind'TKeyNotFoundExceptionif not foundtryFind'T optionfindfilter'T listchoose'U listpartition'T list * 'T listindexedNonEmptyList<int * 'T>unzipNonEmptyList<'T1> * NonEmptyList<'T2>pairwise('T * 'T) listscanNonEmptyList<'State>groupByNonEmptyList<'Key * NonEmptyList<'T>>max'Tmin'TDesign principle: functions that cannot produce an empty result return
NonEmptyList<_>; functions that can produce an empty result return a plain'T list.Tests
16 property-based tests added to
NonEmptyListTests.fs, verifying consistency withListmodule equivalents.Test Status
✅ All 912 tests pass (0 failures, 2 skipped) on ubuntu-latest via
dotnet test. Fantomas formatting check passes.