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
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)
One usage example is provided and documented here.
The Scaladoc API documentation for Scala 3 (valid for Scala 2.13 as well) can be browsed and searched here.
Check the RingSeq website for more info.
The same library is available also for the Python language, check RingSeqPy (Python version).