_aggregate

trait _aggregate[A]
class java.lang.Object
trait scala.Matchable
class Any
trait _use
object Stream

Def

inline def fold(start: A)(f: (A, A) => A): A

Fold

Fold

Folds elements with a binary function

    // Calculate sum of first 1000 Ints

    (1 <> 1000).stream.fold(0)(_ + _) // Returns 500500
Value Params
f

binary function to fold elements with

start

seed value to start with

Source
_aggregate.scala
inline def FOLD(start: A)(f: (A, A) => A): A

Heavy Fold

Heavy Fold

Folds elements with a binary function

FOLD is functionally equivalent to fold, but is fully inlined. It makes compiled code larger, but guarantees the best possible performance on large streams.

Source
_aggregate.scala
inline def FOLD_AS[B](start: B)(f: (B, A) => B): B

Heavy Fold and convert

Heavy Fold and convert

Folds and converts elements with a binary function

FOLD_AS is functionally equivalent to foldAs, but is fully inlined. It makes compiled code larger, but guarantees the best possible performance on large streams.

Source
_aggregate.scala
inline def foldAs[B](start: B)(f: (B, A) => B): B

Fold and convert

Fold and convert

Folds and converts elements with a binary function

    // Calculate sum of first 1000 Ints

    (1 <> 1000).stream.foldAs(0L)(_ + _) // Returns 500500
Value Params
f

binary function to fold elements with Note. When folding AnyRef stream as a primitive value, there will be value boxing. Use FOLD_AS instead, which will be perfectly specialized.

start

seed value to start with

Source
_aggregate.scala
inline def reduce(f: (A, A) => A): A

Reduce

Reduce

Folds elements with a binary function

   // Calculate sum of first 1000 Ints

   (1 <> 1000).stream.reduce(_ + _) // Returns 500500

Note. Threre is no default value, and if stream is empty, operation fails. Use reduceOpt as safer option

Value Params
f

binary function to fold elements with

Source
_aggregate.scala
inline def REDUCE(f: (A, A) => A): A

Heavy reduce

Heavy reduce

Folds elements with a binary function

REDUCE is functionally equivalent to reduce, but is fully inlined. It makes compiled code larger, but guarantees the best possible performance on large streams.

Source
_aggregate.scala
inline def REDUCE_OPT(f: (A, A) => A): Opt[A]

Heavy optional reduce

Heavy optional reduce

Folds elements with a binary function

REDUCE_OPT is functionally equivalent to reduceOpt, but is fully inlined. It makes compiled code larger, but guarantees the best possible performance on large streams.

Source
_aggregate.scala
inline def reduceOpt(f: (A, A) => A): Opt[A]

Optional reduce

Optional reduce

Folds elements with a binary function or returns empty option when stream is empty

    // Calculate sum of first 1000 Ints

    (1 <> 1000).stream.reduceOpt(_ + _) // Returns Opt(500500)
Value Params
f

binary function to fold elements with

Source
_aggregate.scala