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

Scala
import io.github.scala_tessella.ring_seq.RingSeq.given

Seq(1, 2, 3, 4).rotateRight(1)   // Seq(4, 1, 2, 3)
Rust
use ring_seq::RingSeq;

vec![1, 2, 3, 4].rotate_right(1); // [4, 1, 2, 3]
Python
from ring_seq import rotate_right

rotate_right([1, 2, 3, 4], 1)     # [4, 1, 2, 3]
Placeholder: the snippets above are illustrative. Replace each with the canonical idiom from the relevant package README before launch.

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

If you adopt it in a project, open an issue and we will add it to the list.

Install, docs and source

LanguagePackageAPI docsSource
ScalaMaven CentralScaladocGitHub
Rustcrates.iodocs.rsGitHub
PythonPyPImethodsGitHub

For tutorials beyond the quickstart, see /docs/libraries/ring-seq/.