mathrc 0.2.4

Rust Mathematics Library
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
pub struct Seq<S> where S: Fn(u64) -> f64,{
    seq: S,
}

impl<S> Seq<S> where S: Fn(u64) -> f64 {
    pub fn define(seq: S) -> Self {
        Self { seq }
    }

    pub fn nth(&self, n: u64) -> f64 {
        (self.seq)(n)
    }

    pub fn sum(&self, k: u64, n: u64) -> f64 {
        (k..=n).map(|i| (self.seq)(i)).sum()
    }
}