-
Notifications
You must be signed in to change notification settings - Fork 90
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 array.zip_with
and array.imap
to the standard library
#1797
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a fair addition. I wonder about the naming though. OCaml and Scala use map2
instead of zip_with
(and mapi
instead of imap
). Rust doesn't have them, I guess you use .enumerate()
or .zip()
and then do a normal map
. In the JavaScript world, lodash
(some kind of common utility extension of the stdlib) use zipWith.
While I understand why zip_with
makes sense in a language with collections, tuples, curryfication and higher order functions, I wonder if the convention of all those variants being just map
with a different suffix isn't more discoverable. But maybe that's just the stubborn Ocamler inside me 😕
Co-authored-by: Yann Hamdaoui <yann.hamdaoui@tweag.io>
The biggest reason to go with On a side note, an error message in the manual currently depends on the line count of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's discuss that further in the weekly meeting, and merge the implementation as it is. We just need to decide before the next version.
Right, I had the same issue on a recent PR. Maybe we can use the same trick that we use for snapshot testing, where we strip off the local paths and replace them with a generic placeholder (or, rather, a co-placeholder 🤔 - a placetaker ?) |
This change adds the functions
zip_with
andimap
to the array standard library. Both were quite useful in a recent project of mine and seem general enough to warrant inclusion.