algorithms4 0.0.3

A rust implementation of the 4th edition of Algorithms by R. Sedgewick and K. Wayne.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/// Returns an iterator following the geometric series,
/// with *a* being the initial value and *r* being the common ratio
pub(crate) fn geometric_iter(
    a: usize,
    r: usize,
) -> impl Iterator<Item = usize> {
    (0..).map(move |i| a * r.pow(i))
}

/// Returns an iterator following the arithmetic series,
/// with *a* being the initial value and *d* being the common difference
pub(crate) fn arithmetic_iter(
    a: usize,
    d: usize,
) -> impl Iterator<Item = usize> {
    (0..).map(move |i| a + d * i)
}