Provides symmetry operations for a Seq considered circular.
Attributes
Members list
Type members
Inherited types
For improved readability, the index of a Seq.
For improved readability, the index of a circular Seq.
For improved readability, the index of a circular Seq.
Attributes
- Note
-
any value is a valid index, provided that
Seqis not empty - Inherited from:
- IndexingOps
Extensions
Extensions
Calculates the axes of reflectional symmetry. Returns a list of pairs of locations where each axis intersects the cycle.
Calculates the axes of reflectional symmetry. Returns a list of pairs of locations where each axis intersects the cycle.
Attributes
- Returns
-
A list where each pair represents the two points on the cycle where the axis passes.
Computes the order of rotational symmetry possessed by this circular sequence, that is the number of times the sequence matches itself as it makes a full rotation.
Computes the order of rotational symmetry possessed by this circular sequence, that is the number of times the sequence matches itself as it makes a full rotation.
Attributes
- Returns
-
An integer between 1 and the size of the sequence. 1 means no symmetry (only identity), max means a perfect circle (e.g., all elements equal).
- Example
-
Seq(0, 1, 2, 0, 1, 2).rotationalSymmetry // 2
Computes the order of reflectional (mirror) symmetry possessed by this circular sequence.
Computes the order of reflectional (mirror) symmetry possessed by this circular sequence.
Attributes
- Returns
-
the number >= 0 of reflections in which this circular sequence looks exactly the same.
- Example
-
Seq(2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2).symmetry // 4
Finds the indices of each element of this circular sequence close to an axis of reflectional symmetry.
Finds the indices of each element of this circular sequence close to an axis of reflectional symmetry.
Attributes
- Returns
-
the indices of each element of this circular sequence close to an axis of reflectional symmetry, that is a line of symmetry that splits the sequence in two identical halves.
- Example
-
Seq(2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2).symmetryIndices // List(0, 3, 6, 9)
Inherited extensions
Reflects the sequence to start at some circular index.
Reflects the sequence to start at some circular index.
Value parameters
- i
Attributes
- Returns
-
a sequence consisting of all elements reversed and rotated to start at circular index ''i''.
- Example
-
Seq(0, 1, 2).reflectAt() // Seq(0, 2, 1) - Inherited from:
- TransformingOps
Rotates the sequence to the left by some steps.
Rotates the sequence to the left by some steps.
Value parameters
- step
-
the circular distance between each old and new position
Attributes
- Returns
-
a sequence consisting of all elements rotated to the left by ''step'' places. If ''step'' is negative the rotation happens to the right.
- Example
-
Seq(0, 1, 2).rotateLeft(1) // Seq(1, 2, 0) - Inherited from:
- TransformingOps
Rotate the sequence to the right by some steps.
Rotate the sequence to the right by some steps.
Value parameters
- step
-
the circular distance between each new and old position
Attributes
- Returns
-
a sequence consisting of all elements rotated to the right by ''step'' places. If ''step'' is negative the rotation happens to the left.
- Example
-
Seq(0, 1, 2).rotateRight(1) // Seq(2, 0, 1) - Inherited from:
- TransformingOps
Rotates the sequence to start at some circular index.
Rotates the sequence to start at some circular index.
Value parameters
- i
Attributes
- Returns
-
a sequence consisting of all elements rotated to start at circular index ''i''. It is equivalent to rotateLeft.
- Example
-
Seq(0, 1, 2).startAt(1) // Seq(1, 2, 0) - Inherited from:
- TransformingOps
Gets the element at some circular index.
Gets the element at some circular index.
Value parameters
- i
Attributes
- Throws
-
java.lang.ArithmeticException
if
Seqis empty - Example
-
Seq(0, 1, 2).applyO(3) // 0 - Inherited from:
- IndexingOps
Normalize a given index of a circular Seq