-
Notifications
You must be signed in to change notification settings - Fork 115
add @array.zip and @array.zip_with #1575
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
base: main
Are you sure you want to change the base?
Conversation
Pull Request Test Coverage Report for Build 6413Details
💛 - Coveralls |
c82b1f9
to
01aafb4
Compare
I have an API design concern, with Array zip, what about FixedArray? What about other linearly traversable structures? This leads to the discussion that Iter::zip, but our Iter can't do zip... cc @bobzhang |
It seems |
related issue. |
There is a zip function in /// Zip two lists.
/// If the lists have different lengths, it will return None.
pub fn zip[A, B](self : T[A], other : T[B]) -> T[(A, B)]? It's a method that returns an option. To make the API more consistent, consider changing the API like this: // in immut/list
pub fn zip[A, B](self : T[A], other : T[B]) -> T[(A, B)]
// in array
pub fn zip[A, B](self : T[A], other : T[B]) -> T[(A, B)]
pub fn zip_with[A, B, C](self : T[A], other : T[B], merge~ : (A,B)->C) -> T[C] |
3c82d74
to
eb98c89
Compare
So that the zip for FixedArray is a todo issue? |
8be12fd
to
812a595
Compare
Different behaviors between Array.zip and List.zip may confuse usersCategory // List.zip behavior changed from returning Option to truncating zip_to_iter2 lacks documentation about early termination behaviorCategory Array capacity pre-allocation could be optimized in zip functionsCategory |
array/array.mbt
Outdated
pub fn zip_with[A, B, C]( | ||
l : Array[A], | ||
r : Array[B], | ||
merge~ : (A, B) -> C |
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.
without labelled argument
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.
Provide zip_to_iter
for creating Iter2
29bc8d3
to
64f58b6
Compare
…/list.zip with @array.zip
64f58b6
to
5c8e9b6
Compare
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.
drop the changes in immut/list
as they are irrelevant and we are going to deprecate them.
No description provided.