Trait std::iter::MultiplicativeIterator
pub trait MultiplicativeIterator<A> { fn product(&mut self) -> A; }
A trait for iterators over elements whose elements can be multiplied together.
Required Methods
fn product(&mut self) -> A
Iterates over the entire iterator, multiplying all the elements
Example
use std::iter::{count, MultiplicativeIterator}; fn factorial(n: uint) -> uint { count(1u, 1).take_while(|&i| i <= n).product() } assert!(factorial(0) == 1); assert!(factorial(1) == 1); assert!(factorial(5) == 120);
Implementors
impl<A: Mul<A, A> + One, T: Iterator<A>> MultiplicativeIterator<A> for T