How to make zip work with more than 6 elements?

Open
#1,175 6 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
38/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
rust
Domain
data

Research direction

Start with the Zip::from, .and, and .for_each entry points and the compiler example at src/main.rs:47. Review how support for the existing producer counts is organized, then verify that the seven-producer example compiles and executes with the expected values.

Written by the indexing model from the issue text.

Description

I want to use zip (or azip!) with 7 producers but its only implemented for max 6 producers. Is there a convenient way to also implement it for more producers?

Minimal Example Code:

let v1: Array1<i32> = Array1::zeros(3);
let v2: Array1<i32> = Array1::zeros(3);
let v3: Array1<i32> = Array1::zeros(3);
let v4: Array1<i32> = Array1::zeros(3);
let v5: Array1<i32> = Array1::zeros(3);
let v6: Array1<i32> = Array1::zeros(3);
let v7: Array1<i32> = Array1::zeros(3);
Zip::from(&v1)
	.and(&v2)
	.and(&v3)
	.and(&v4)
	.and(&v5)
	.and(&v6)
	.and(&v7)
	.for_each(|v1, v2, v3, v4, v5, v6, v7| {
		println!("{}, {}, {}, {}, {}, {}, {}", v1, v2, v3, v4, v5, v6, v7);
	});

Error:

error[E0599]: no method named and found for struct ndarray::Zip<(ArrayBase<ViewRepr<&i32>, Dim<[usize; 1]>>, ArrayBase<ViewRepr<&i32>, Dim<[usize; 1]>>, ArrayBase<ViewRepr<&i32>, Dim<[usize; 1]>>, ArrayBase<ViewRepr<&i32>, Dim<[usize; 1]>>, ArrayBase<ViewRepr<&i32>, Dim<[usize; 1]>>, ArrayBase<ViewRepr<&i32>, Dim<[usize; 1]>>), Dim<[usize; 1]>> in the current scope
--> src\main.rs:47:14
|
47 | .and(&v7)
| ^^^ method not found in ndarray::Zip<(ArrayBase<ViewRepr<&i32>, Dim<[usize; 1]>>, ArrayBase<ViewRepr<&i32>, Dim<[usize; 1]>>, ArrayBase<ViewRepr<&i32>, Dim<[usize; 1]>>, ArrayBase<ViewRepr<&i32>, Dim<[usize; 1]>>, ArrayBase<ViewRepr<&i32>, Dim<[usize; 1]>>, ArrayBase<ViewRepr<&i32>, Dim<[usize; 1]>>), Dim<[usize; 1]>>
|
= note: the method was found for
- ndarray::Zip<(P1,), D>
- ndarray::Zip<(P1, P2), D>
- ndarray::Zip<(P1, P2, P3), D>
- ndarray::Zip<(P1, P2, P3, P4), D>
- ndarray::Zip<(P1, P2, P3, P4, P5), D>

Dominant language
Rust
Stars
4.3k
Forks
391
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rust-ndarray/ndarray

All issues in rust-ndarray/ndarray

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.