scala-tessella / ring-seq   0.6.2

Apache License 2.0 Website GitHub

Extends Scala Seq with ring (circular) methods

Scala versions: 3.x 2.13
Scala.js versions: 1.x

RingSeq

ring-seq Scala version support Maven Central Scala.js CI Scala Steward badge

A library that adds new operations to Scala Seq for when a sequence needs to be considered circular, its elements forming a ring.

It works on any immutable / mutable Seq and sub-types.

Available for Scala 3.3.3 and 2.13.13, compatible with Scala.js

Setup

Add the following dependency to your build.sbt file:

libraryDependencies += "io.github.scala-tessella" %% "ring-seq" % "0.6.2" // Use %%% instead of %% if you're using ScalaJS

Then just import the RingSeq object, any collection under Seq will access the new methods.

import io.github.scala_tessella.ring_seq.RingSeq._

"RING".rotateRight(1).mkString // GRIN
List(0, 1, 2, 3).startAt(2) // List(2, 3, 0, 1)
ListBuffer(1, 3, 5, 7, 9).reflectAt(3) // ListBuffer(7, 5, 3, 1, 9)

Documentation

Usage

One usage example is provided and documented here.

Scaladoc

The Scaladoc API documentation for Scala 3 (valid for Scala 2.13 as well) can be browsed and searched here.

Website

Check the RingSeq website for more info.

Other languages

The same library is available also for the Python language, check RingSeqPy (Python version).