ring-seq — operations on sequences as rings
A small, self-contained library for cyclic-sequence operations, available in Scala, Rust and Python.
A ring sequence is a sequence whose ends are joined, so rotations
and reflections are meaningful operations. ring-seq provides a
small, well-defined set of those operations: rotate, reflect,
detect palindromes under rotation, slide windows that wrap, and
test sequences for equivalence under rotation or reflection.
Two motivating examples: classifying vertex configurations in a
tessellation (where 3.6.3.6 and 6.3.6.3 describe the same
vertex, just walked from a different starting edge), and rotational
matching on circular DNA. Anything else genuinely cyclical fits.
Quickstart in three languages
import io.github.scala_tessella.ring_seq.RingSeq.given
Seq(1, 2, 3, 4).rotateRight(1) // Seq(4, 1, 2, 3) use ring_seq::RingSeq;
vec![1, 2, 3, 4].rotate_right(1); // [4, 1, 2, 3] from ring_seq import rotate_right
rotate_right([1, 2, 3, 4], 1) # [4, 1, 2, 3] Why three languages
The library is small and self-contained, so porting it once per ecosystem costs less than asking Rust users to call into Scala or Python users to install a JVM. The three implementations are kept in lockstep by a shared specification — adding a new operation means updating the spec and three test suites in tandem.
Where it’s used
- Tessella uses
ring-seqto compare vertex configurations and analyse face boundaries.
If you adopt it in a project, open an issue and we will add it to the list.
Install, docs and source
| Language | Package | API docs | Source |
|---|---|---|---|
| Scala | Maven Central | Scaladoc | GitHub |
| Rust | crates.io | docs.rs | GitHub |
| Python | PyPI | methods | GitHub |
For tutorials beyond the quickstart, see
/docs/libraries/ring-seq/.