_calculate
Def
Average
Average
Computes average
For empty Stream returns zero value
(10 <> 15).stream.map(_.toFloat).average // Returns 12.5
Note: average is available for types providing given Math.Average implementations, which are by default Double, Float and opaque numerals based on Double and Float
- Source
- _calculate.scala
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).stream.averageFew(_ * 10F, _ * 100F).tp // Prints (5005, 50050)
val (first, second, third) = (1 <> 1000).stream.averageFew(v => v.toDouble, _ * 10.0, _ * 100.0)
first.tp // Prints 500.5
second.tp // Prints 5005.0
third.tp // Prints 50050.0
Note: Averages areavailable for types providing given Stream.Custom.Average implementations, which are by default Double, Float and opaque numerals based on Double and Float
- Source
- _calculate.scala
Average option
Average option
Computes average or returns void option for empty stream
(10 <> 15).stream.map(_.toFloat).averageOpt // Returns Opt(12.5)
Note: averageOpt is available for types providing given Math.Average implementations, which are by default Double, Float and opaque numerals based on Double and Float
- Source
- _calculate.scala
Maximum by property
Maximum by property
Computes maximum value based on given function
Fails for empty streams
- Source
- _calculate.scala
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
Optional maximum
Optional maximum
Computes maximum value or returns void option for empty streams
- Source
- _calculate.scala
Minimum by property
Minimum by property
Computes minimum value based on given function
Fails for empty streams
- Source
- _calculate.scala
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
Optional minimum
Optional minimum
Computes minimum value or returns void option for empty streams
- Source
- _calculate.scala
Optional range
Optional range
Computes value value or returns void option for empty streams
- Source
- _calculate.scala
Sum
Sum
Calculates sum of all values
For empty stream returns zero
(1 <> 1000).stream.sum.tp // Prints 500500
- Source
- _calculate.scala
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).stream.sumFew(_ * 10, _ * 100).tp // Prints (5005000, 50050000)
val (first, second, third) = (1 <> 1000).stream.sumFew(v => v, _ * 10, _ * 100)
first.tp // Prints 500500
second.tp // Prints 5005000
third.tp // Prints 50050000
- Source
- _calculate.scala
Optional sum
Optional sum
Calculates sum of all values or returns void option for empty streams
(1 <> 1000).stream.sumOpt.tp // Prints Opt(500500)
- Source
- _calculate.scala