problemutils.extensions

Extensions

Extensions

extension [A](a: A)
def getType(implicit ct: ClassTag[A]): String
def lg: A

Logs any object a in the console without the "[*]" prefix and then returns the object without modifying it.

Logs any object a in the console without the "[*]" prefix and then returns the object without modifying it.

def log: A

Logs any object a in the console and then returns the object without modifying it.

Logs any object a in the console and then returns the object without modifying it.

def logAttr[B](f: A => B): A

Logs any attribute of object a in the console and then returns the object without modifying it.

Logs any attribute of object a in the console and then returns the object without modifying it.

def logCol(color: String): A

Similar to log, but takes a color parameter.

Similar to log, but takes a color parameter.

def logIf(p: A => Boolean): A

Logs any object a in the console if the condition p is satisfied and then returns the object without modifying it.

Logs any object a in the console if the condition p is satisfied and then returns the object without modifying it.

def space: A

Prints an empty line in the console and returns the object without modifying it. Useful for debugging.

Prints an empty line in the console and returns the object without modifying it. Useful for debugging.

extension [A](a: A)
def converge(f: A => A): A

Recursively applies a function f: A => A on any object a until f(a) is equal to a.

Recursively applies a function f: A => A on any object a until f(a) is equal to a.

def doUntil(p: A => Boolean)(f: A => A): A

Recursively applies a function f: A => A on any object a until the predicate p is satisfied.

Recursively applies a function f: A => A on any object a until the predicate p is satisfied.

def expand(f: A => IterableOnce[A]): Set[A]

Performs a flood-fill using a neighbour function f: A => IterableOnce[A]. Returns a set of all elements generated by the function with the starting point a.

Performs a flood-fill using a neighbour function f: A => IterableOnce[A]. Returns a set of all elements generated by the function with the starting point a.

def iterate(f: A => A)(n: Int): A

Applies any function A => A on any object n times. If n is less than or equal to 0, the original object is returned without function application.

Applies any function A => A on any object n times. If n is less than or equal to 0, the original object is returned without function application.

extension [V](a: V)
def ->>(b: V): Edge[V]
extension [A](mat: Matrix[Matrix[A]])
def flatten: Matrix[A]
extension (p: Boolean)
def toInt: Int
extension (p: Int)
def toBoolean: Boolean
extension (str: String)
def findAllMatchWith(regex: String): List[Match]
def findAllWith(regex: String): List[String]
def findMatchWith(regex: String): Option[Match]
def findWith(regex: String): Option[String]
def padLeftTo(n: Int, char: Char): String
def rows: List[String]
def words: List[String]
extension (tup: Pos2D)
def +(other: Pos2D): (Int, Int)
def -(other: Pos2D): (Int, Int)
def col: Int
def distance(other: Pos2D): Double
def dl: Pos2D
def down: Pos2D
def dr: Pos2D
def left: Pos2D
def manhattan(other: Pos2D): Int
def move(dir: Cardinal): Pos2D
def neighbours: List[Pos2D]
def neighboursDiagIn[A](using mat: Matrix[A]): List[A]
def neighboursIn[A](using mat: Matrix[A]): List[A]
def neighboursOrthIn[A](using mat: Matrix[A]): List[A]
def row: Int
def toVector: Vector[Int]
def ul: Pos2D
def up: Pos2D
def ur: Pos2D
def x: Int
def y: Int
extension (v: Pos3D)
def +(other: Pos3D): (Int, Int, Int)
def -(other: Pos3D): (Int, Int, Int)
def distance(other: Pos3D): Double
def manhattan(other: Pos3D): Int
def move(dir: Hex): (Int, Int, Int)
def q: Int
def r: Int
def s: Int
def toVector: Vector[Int]
def x: Int
def y: Int
def z: Int
extension [A](vss: Seq[Seq[A]])
extension [A](xs: Vector[A])
infix def cross(ys: Vector[A])(implicit evidence$3: Numeric[A]): Vector[A]

Computes the cross product of 2 vectors of length 3.

Computes the cross product of 2 vectors of length 3.

infix def dot(ys: Vector[A])(implicit evidence$2: Numeric[A]): A

Computes the dot product of 2 vectors of the same length.

Computes the dot product of 2 vectors of the same length.

def magnitude(implicit evidence$4: Numeric[A]): Double

Returns the magnitude of this vector.

Returns the magnitude of this vector.

def normalized(implicit evidence$5: Numeric[A]): Vector[Double]

Returns a normalized version of this vector.

Returns a normalized version of this vector.

def toVec3(implicit evidence$1: Numeric[A]): (Int, Int, Int)
extension [A](xs: Seq[A])
def average(using Numeric[A]): Double
def median(using Numeric[A], Ordering[A]): Double
def reshape(height: Int, width: Int): Matrix[A]

Reshapes this sequence into a problemutils.classes.Matrix of the given width and height.

Reshapes this sequence into a problemutils.classes.Matrix of the given width and height.

def rms(using Numeric[A]): Double

Computes the root mean square of this sequence.

Computes the root mean square of this sequence.