seqgen

Sequence generation library

seqgen is a library that lets you generate sequences in a performant and easy way. seqgen is lazy meaning the elements won't be generated until needed or explicitly requested. The sequences generated by seqgen implement the Iterator trait so manipulation is done using familiar rust iterators syntax.

New is this release:

Install:

From the commend line in your project directory run the following

console $ cargo add seqgen

Or add this under [[dependencies]] in Cargo.toml file

toml seqgen = "0.2.3"

Examples:

Fibonacci sequence

```rust use seqgen::prelude::*;

fn main() { let fibseq = Sequence::new() .initialelements(vec![0, 1u128]) .transitionfunction(|aliveelements, currentindex| { aliveelements.nthelement(currentindex - 1).unwrap() + aliveelements.nthelement(currentindex - 2).unwrap() }) .pre_generate(185);

fib_seq
    .alive_elements()
    .for_each(|element| println!("{element}"));

} ```

An x-y sequence

```rust use seqgen::prelude::*;

fn main() { let mut seq = Sequence::new() .initialelements(vec!["x".tostring(), "y".tostring()]) .transitionfunction(|aliveelements, currentelementindex| { let mut string = String::from( aliveelements .nthelement(currentelement_index - 2) .unwrap(), );

        string.push_str(
            alive_elements
                .nth_element(current_element_index - 1)
                .unwrap(),
        );

        string
    });

seq.range(0, 10)
    .unwrap()
    .for_each(|element| println!("{element}"));

} ```

Range of sequence

```rust use seqgen::prelude::*;

fn main() { let mut seq = Sequence::new() .transitionfunction(|aliveelements, currentelementindex| { aliveelements .lastelement() .mapor(currentelement_index, |element| element + 1) });

let range_res = seq.range(0, 10);

if let Ok(range) = range_res {
    range.for_each(|element| println!("{element}"));
}

} ```

Have suggestions? contribute to the project or open an issue on GitHub.