summaryrefslogtreecommitdiff
path: root/src/poly/iter.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/poly/iter.rs')
-rw-r--r--src/poly/iter.rs16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/poly/iter.rs b/src/poly/iter.rs
index 26c5989..abc7462 100644
--- a/src/poly/iter.rs
+++ b/src/poly/iter.rs
@@ -1,13 +1,23 @@
use crate::number::Number;
+use std::cmp;
+use std::iter::{Zip, Take};
pub struct Iter {
index: usize,
- data: Vec<Number>
+ data: Vec<Number>,
+ degree: usize
}
impl Iter {
- pub fn new(data: Vec<Number>) -> Iter {
- Iter { index: 0, data }
+ pub fn new(data: Vec<Number>, degree: usize) -> Iter {
+ Iter { index: 0, data, degree }
+ }
+
+ pub fn zip(self, other: Self) -> Zip<Take<Iter>, Take<Iter>> {
+ let deg = cmp::max(self.degree, other.degree) + 1;
+ let a = self.take(deg);
+ let b = other.take(deg);
+ a.zip(b)
}
}