_aggregate
Def
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
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
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
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
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
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
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
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