problemutils.extensions

Members list

Value members

Concrete methods

def fst[A, B](tup: (A, B)): A
def snd[A, B](tup: (A, B)): B

Extensions

Extensions

extension [A](a: 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.

Attributes

def doUntil(f: A => A)(p: A => Boolean): 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.

Attributes

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

Returns a set of all elements reachable from the starting point a using a "neighbour function" f: A => IterableOnce[A].

Returns a set of all elements reachable from the starting point a using a "neighbour function" f: A => IterableOnce[A].

Attributes

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.

Attributes

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

Applies any function A => B on any object a and then returns the result.

Applies any function A => B on any object a and then returns the result.

Attributes

def tap(f: A => Unit): A

Applies any function A => Unit on any object a and then returns the object without modifying it.

Applies any function A => Unit on any object a and then returns the object without modifying it.

Attributes

extension [A](a: 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.

Attributes

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.

Attributes

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.

Attributes

def logAttrIf[B](f: A => B)(p: B => Boolean): A

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

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

Attributes

def logCol(color: String): A

Similar to log, but takes a color parameter.

Similar to log, but takes a color parameter.

Attributes

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.

Attributes

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.

Attributes

extension [V](a: V)(a: V)
def ->>(b: V): Edge[V]
extension [A, B](map: Map[A, B])(map: Map[A, B])
def invert: Map[B, Set[A]]
extension [A](mat: Matrix[Matrix[A]])(mat: Matrix[Matrix[A]])
def flatten: Matrix[A]
extension (p: Boolean)(p: Boolean)
def toInt: Int
extension (p: Int)(p: Int)
def toBoolean: Boolean
extension (str: String)(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)(tup: Pos2D)
def %(other: Pos2D): (Int, Int)
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 neighboursDiag: List[Pos2D]
def neighboursDiagIn[A](using mat: Matrix[A]): List[A]
def neighboursIn[A](using mat: Matrix[A]): List[A]
def neighboursOrth: List[Pos2D]
def neighboursOrthIn[A](using mat: Matrix[A]): List[A]
def right: Pos2D
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)(v: Pos3D)
def +(other: Pos3D): (Int, Int, Int)
def -(other: Pos3D): (Int, Int, Int)
def distance(other: Pos3D): Double
def down: Pos3D
def in: Pos3D
def left: Pos3D
def manhattan(other: Pos3D): Int
def move(dir: Hex): (Int, Int, Int)
def out: Pos3D
def q: Int
def r: Int
def right: Pos3D
def s: Int
def toVector: Vector[Int]
def up: Pos3D
def x: Int
def y: Int
def z: Int
extension [A](vss: Seq[Seq[A]])(vss: Seq[Seq[A]])
def toMatrix: Matrix[A]
extension [A](xs: IterableOnce[A])(xs: IterableOnce[A])
def average(using Numeric[A]): Double
def median(using Numeric[A], Ordering[A]): Double
def productBy[B](f: A => B)(using num: Numeric[B]): B
def rms(using Numeric[A]): Double

Computes the root mean square of this sequence.

Computes the root mean square of this sequence.

Attributes

def sumBy[B](f: A => B)(using num: Numeric[B]): B
extension [A](xs: Seq[A])(xs: Seq[A])
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.

Attributes

def split(elem: A): List[Seq[A]]
extension [A](xs: Vector[A])(xs: Vector[A])(implicit evidence$2: Numeric[A])
infix def dot(ys: Vector[A]): A

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

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

Attributes

extension [A](xs: Vector[A])(xs: Vector[A])(implicit evidence$3: Numeric[A])
infix def cross(ys: Vector[A]): Vector[A]

Computes the cross product of 2 vectors of length 3.

Computes the cross product of 2 vectors of length 3.

Attributes

extension [A](xs: Vector[A])(xs: Vector[A])
def magnitude: Double

Returns the magnitude of this vector.

Returns the magnitude of this vector.

Attributes

def normalized: Vector[Double]

Returns a normalized version of this vector.

Returns a normalized version of this vector.

Attributes

def toVec3: (Int, Int, Int)