_calculate

trait _calculate
class java.lang.Object
trait scala.Matchable
class Any
trait _use
object ~

Def

@scala.annotation.targetName("average")
def average[A](using v: ~~.Custom.Math.Average[A]): A

Average

Average

Computes average

For empty Stream returns zero value

   (10 <> 15).~.map(_.Float).average  // Returns 12.5

Note: average is available for types providing given ~~.Custom.Math.Average implementations, which are by default Double, Float and opaque numerics based on Double and Float

Source
_calculate.scala
@scala.annotation.targetName("average_Opt")
def average_?[A](using v: ~~.Custom.Math.Average[A]): Opt[A]

Average option

Average option

Computes average or returns void option for empty stream

   (10 <> 15).~.map(_.Float).average_?  // Returns Opt(12.5)

Note: average_? is available for types providing given ~~.Custom.Math.Average implementations, which are by default Double, Float and opaque numerics based on Double and Float

Source
_calculate.scala
def averageFew[A](fb: A => Opt[B], fc: A => Opt[C], fd: A => Opt[D], fe: A => Opt[E], ff: A => Opt[F])(using nb: ~~.Custom.Math.Average[B], nc: ~~.Custom.Math.Average[C], nd: ~~.Custom.Math.Average[D], ne: ~~.Custom.Math.Average[E], nf: ~~.Custom.Math.Average[F]): (B, C) | (B, C, D) | (B, C, D, E) | (B, C, D, E, F)

Multi average

Multi average

Simultaneously computes up to 5 average values for properties specified by functions

Returns tuple of appropriate size with values corresponding to the given mappings

For empty Stream returned tuple will hold zeros

   (1 <> 1000).~.averageFew(_ * 10F, _ * 100F).tp  // Prints (5005, 50050)

    val (first, second, third) = (1 <> 1000).~.averageFew(v => v.Double, _ * 10.0, _ * 100.0)

    first.tp     // Prints 5005
    second.tp    // Prints 5005
    third.tp     // Prints 5005

Note: Averages areavailable for types providing given ~~.Custom.Average implementations, which are by default Double, Float and opaque numerics based on Double and Float

Source
_calculate.scala
@scala.annotation.targetName("max")
def max[A](using scala.Ordering[A]): A

Maximum

Maximum

Computes maximum value

Fails for empty streams

Source
_calculate.scala
@scala.annotation.targetName("max_Opt")
def max_?[A](using c: scala.Ordering[A]): Opt[A]

Optional maximum

Optional maximum

Computes maximum value or returns void option for empty streams

Source
_calculate.scala
@scala.annotation.targetName("maxBy")
def maxBy[A](f: A => B)(using scala.Ordering[B]): A

Maximum by property

Maximum by property

Computes maximum value based on given function

Fails for empty streams

Source
_calculate.scala
@scala.annotation.targetName("maxBy_Opt")
def maxBy_?[A](f: A => B)(using c: scala.Ordering[B]): Opt[A]

Optional maximum by property

Optional maximum by property

Computes maximum value based on given function or returns void option for empty streams

Source
_calculate.scala
@scala.annotation.targetName("min")
def min[A](using scala.Ordering[A]): A

Minimum

Minimum

Computes minimum value

Fails for empty streams

Source
_calculate.scala
@scala.annotation.targetName("min_Opt")
def min_?[A](using c: scala.Ordering[A]): Opt[A]

Optional minimum

Optional minimum

Computes minimum value or returns void option for empty streams

Source
_calculate.scala
@scala.annotation.targetName("minBy")
def minBy[A](f: A => B)(using scala.Ordering[B]): A

Minimum by property

Minimum by property

Computes minimum value based on given function

Fails for empty streams

Source
_calculate.scala
@scala.annotation.targetName("minBy_Opt")
def minBy_?[A](f: A => B)(using c: scala.Ordering[B]): Opt[A]

Optional minimum by property

Optional minimum by property

Computes minimum value based on given function or returns void option for empty streams

Source
_calculate.scala
@scala.annotation.targetName("range")
def range[A](using scala.Ordering[A]): <>[A]

Range

Range

Computes value range

Fails for empty streams

Source
_calculate.scala
@scala.annotation.targetName("range_Opt")
def range_?[A](using c: scala.Ordering[A]): Opt[<>[A]]

Optional range

Optional range

Computes value value or returns void option for empty streams

Source
_calculate.scala
@scala.annotation.targetName("sum")
def sum[A](using n: Math[A]): A

Sum

Sum

Calculates sum of all values

For empty stream returns zero

    (1 <> 1000).~.sum.tp // Prints 500500
Source
_calculate.scala
@scala.annotation.targetName("sum_Opt")
def sum_?[A](using n: Math[A]): Opt[A]

Optional sum

Optional sum

Calculates sum of all values or returns void option for empty streams

    (1 <> 1000).~.sum_?.tp // Prints Opt(500500)
Source
_calculate.scala
def sumFew[A](fb: A => Opt[B], fc: A => Opt[C], fd: A => Opt[D], fe: A => Opt[E], ff: A => Opt[F])(using nb: Math[B], nc: Math[C], nd: Math[D], ne: Math[E], nf: Math[F]): (B, C) | (B, C, D) | (B, C, D, E) | (B, C, D, E, F)

Multi sum

Multi sum

Simultaneously computes up to 5 sum values for properties specified by given functions

Returns tuple of appropriate size with values corresponding to the given mappings

For empty Stream returned tuple will hold zeros

 (1 <> 1000).~.sumFew(_ * 10, _ * 100).tp  // Prints (5005000, 50050000)

 val (first, second, third) = (1 <> 1000).~.sumFew(v => v, _ * 10, _ * 100)

 first.tp     // Prints 500500
 second.tp    // Prints 5005000
 third.tp     // Prints 50050000
Source
_calculate.scala