Closed wangjiawen2013 closed 7 months ago
But there is no iterator that zip an unknown number of iterators. The example suggested seems decent to me
struct Multizip<T>(Vec<T>);
impl<T> Iterator for Multizip<T>
where
T: Iterator,
{
type Item = Vec<T::Item>;
fn next(&mut self) -> Option<Self::Item> {
self.0.iter_mut().map(Iterator::next).collect()
}
}
It could at least have a size hint. And it imposes a same iterator type which does not seem very helpful. Each can be boxed vec![Box::new(0..2), Box::new(2..=5), ...]
though.
Would you elaborate on what you need?
I want to zip columns of Polars dataframe, but sometimes there are a lot number of columns, I must put all the columns (which have been converted to vectors) using izip! manually. It's very inconvinenced.
That sure seems painful.
I'm not familiar with Polars but "zip columns" is not just rows? in which case there sure is a method for it. Unless it's hidden behind the crate feature "rows" that you might need to add first (based on this).
Hi, who can helps ?
https://stackoverflow.com/questions/55291961/how-can-i-zip-together-an-unknown-at-compile-time-number-of-iterators
https://stackoverflow.com/questions/29669287/how-can-i-zip-more-than-two-iterators