Rename Array::zip to Array::fold
(woops!)
This commit is contained in:
parent
1a94e8d06e
commit
59a46bc7ab
2 changed files with 6 additions and 6 deletions
|
@ -40,7 +40,7 @@ pub trait Array
|
||||||
*self.mut_i(b) = tmp;
|
*self.mut_i(b) = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn zip(&self, f: &fn(&T, &T) -> T) -> T;
|
fn fold(&self, f: &fn(&T, &T) -> T) -> T;
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! array(
|
macro_rules! array(
|
||||||
|
@ -87,8 +87,8 @@ macro_rules! array(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn zip(&self, f: &fn(&$T, &$T) -> $T) -> $T {
|
fn fold(&self, f: &fn(&$T, &$T) -> $T) -> $T {
|
||||||
gen_zip!($_n)
|
gen_fold!($_n)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -105,7 +105,7 @@ macro_rules! gen_builder(
|
||||||
(_4) => ([builder(0), builder(1), builder(2), builder(3)]);
|
(_4) => ([builder(0), builder(1), builder(2), builder(3)]);
|
||||||
)
|
)
|
||||||
|
|
||||||
macro_rules! gen_zip(
|
macro_rules! gen_fold(
|
||||||
(_2) => (f(self.i(0), self.i(1)));
|
(_2) => (f(self.i(0), self.i(1)));
|
||||||
(_3) => (f(&f(self.i(0), self.i(1)), self.i(2)));
|
(_3) => (f(&f(self.i(0), self.i(1)), self.i(2)));
|
||||||
(_4) => (f(&f(&f(self.i(0), self.i(1)), self.i(2)), self.i(3)));
|
(_4) => (f(&f(&f(self.i(0), self.i(1)), self.i(2)), self.i(3)));
|
||||||
|
|
|
@ -130,10 +130,10 @@ pub trait Vector
|
||||||
#[inline] fn rem_self_v(&mut self, other: &Self);
|
#[inline] fn rem_self_v(&mut self, other: &Self);
|
||||||
|
|
||||||
/// The sum of each component of the vector.
|
/// The sum of each component of the vector.
|
||||||
#[inline] fn comp_add(&self) -> S { self.zip(|a, b| a.add(b)) }
|
#[inline] fn comp_add(&self) -> S { self.fold(|a, b| a.add(b)) }
|
||||||
|
|
||||||
/// The product of each component of the vector.
|
/// The product of each component of the vector.
|
||||||
#[inline] fn comp_mul(&self) -> S { self.zip(|a, b| a.mul(b)) }
|
#[inline] fn comp_mul(&self) -> S { self.fold(|a, b| a.mul(b)) }
|
||||||
|
|
||||||
/// Vector dot product.
|
/// Vector dot product.
|
||||||
#[inline] fn dot(&self, other: &Self) -> S { self.mul_v(other).comp_add() }
|
#[inline] fn dot(&self, other: &Self) -> S { self.mul_v(other).comp_add() }
|
||||||
|
|
Loading…
Reference in a new issue