I have been writing a crate for low-level operations on polynomials. Most functions in that crate work with a sequence of coefficients. Using an ndarray::ArrayBase
for the coefficients seems logical, but I didn't want to rule out alternatives, in particular a simple slice. So I created sqnc
: sequence traits with adaptors similar to Iterator
. The crate is free of allocation, doesn't require std and provides implementations for slice, array, std::ops::Range
and ndarray::ArrayBase
. To whet your appetite, here's a boring example using Sequence::get()
:
use sqnc::Sequence;
let x = 4..8; // `std::ops::Range<usize>`, implements `Sequence`
assert_eq!(x.get(1), Some(5));
And an example showing off the adaptors Sequence::select()
and Sequence::copied()
:
use sqnc::Sequence;
let x = *b"cdelst!"; // array of `u8`, implements `Sequence`
let y = x.select([4, 2, 3, 2, 0, 5, 2, 1, 6].copied()).unwrap();
assert!(y.iter().eq(b"selected!"));