Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add partitionMap to Iterable (#3001) #3004

Merged
merged 2 commits into from
Mar 30, 2023

Conversation

jsoizo
Copy link
Contributor

@jsoizo jsoizo commented Mar 29, 2023

Implementation for #3001

Copy link
Member

@nomisRev nomisRev left a comment

Choose a reason for hiding this comment

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

PR looks perfect thank you for your contribution @jsoizo 🙌 Congrats on your first contribution 🥳

* <!--- KNIT example-iterable-20.kt -->
* <!--- TEST lines.isEmpty() -->
*/
public inline fun <T, A, B> Iterable<T>.partitionMap(f: (T) -> Either<A, B>): Pair<List<A>, List<B>> {
Copy link
Member

Choose a reason for hiding this comment

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

Wondering about the name 🤔 I asked chat-gpt 😁 It suggested seperateMap, it would be more aligned with seperateEither. What do you think?

Copy link
Contributor Author

@jsoizo jsoizo Mar 30, 2023

Choose a reason for hiding this comment

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

@nomisRev I didn't have a particularly strong opinion on the naming of this function, and thought it would be fine as it is in Scala's partitionMap.
As you mention in the Kotlin slack, I prefer to assume that Iterable<Either<A,B>>.separateEither overloads this. I would change it that way.

Copy link
Member

Choose a reason for hiding this comment

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

I have no strong opinion towards any names, but I just feel that they should be aligned. I somehow missed that Kotlin Std already has partition.

Haskell names seperateEither as partitionEither so in that case partitionEither and partitionMap would make sense. I invited some other reviewers to the PR.

Copy link
Collaborator

@franciscodr franciscodr left a comment

Choose a reason for hiding this comment

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

Looks good to me. Thanks for your contribution, @jsoizo!

Copy link
Collaborator

@gutiory gutiory left a comment

Choose a reason for hiding this comment

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

Looks great!
Thanks @jsoizo !!!

@serras serras merged commit d3f8ee1 into arrow-kt:main Mar 30, 2023
@jsoizo jsoizo deleted the iterable-partitionmap branch March 30, 2023 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants