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 @array.zip and @array.zip_with #1575

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Conversation

myfreess
Copy link
Contributor

No description provided.

@coveralls
Copy link
Collaborator

coveralls commented Jan 26, 2025

Pull Request Test Coverage Report for Build 5446

Details

  • 13 of 13 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.03%) to 92.607%

Totals Coverage Status
Change from base Build 5440: 0.03%
Covered Lines: 5875
Relevant Lines: 6344

💛 - Coveralls

@myfreess myfreess force-pushed the myfreess/add-array-zip branch 2 times, most recently from c82b1f9 to 01aafb4 Compare January 26, 2025 04:46
@myfreess myfreess requested a review from Yoorkin January 26, 2025 06:05
@Lampese
Copy link
Collaborator

Lampese commented Jan 27, 2025

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

@FlammeShadow
Copy link
Contributor

It seems zip_with can be easily composed with zip and map?

@illusory0x0
Copy link
Contributor

related issue.

@Yoorkin
Copy link
Collaborator

Yoorkin commented Feb 18, 2025

There is a zip function in immut/list:

/// 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]

@myfreess myfreess force-pushed the myfreess/add-array-zip branch from bb37517 to 3c82d74 Compare February 18, 2025 07:58
@myfreess myfreess force-pushed the myfreess/add-array-zip branch from 3c82d74 to eb98c89 Compare February 18, 2025 08:03
@Lampese
Copy link
Collaborator

Lampese commented Feb 18, 2025

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

So that the zip for FixedArray is a todo issue?

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.

6 participants