reduce

inline fun ByteBuffer.reduce(operation: (acc: Byte, Byte) -> Byte): Byte
inline fun ShortBuffer.reduce(operation: (acc: Short, Short) -> Short): Short
inline fun IntBuffer.reduce(operation: (acc: Int, Int) -> Int): Int
inline fun LongBuffer.reduce(operation: (acc: Long, Long) -> Long): Long
inline fun FloatBuffer.reduce(operation: (acc: Float, Float) -> Float): Float
inline fun DoubleBuffer.reduce(operation: (acc: Double, Double) -> Double): Double
inline fun CharArray.reduce(operation: (acc: Char, Char) -> Char): Char

Accumulates value starting with the first element and applying operation from left to right to current accumulator value and each element.

Throws an exception if this array is empty. If the array can be empty in an expected way, please use reduceOrNull instead. It returns null when its receiver is empty.

Samples

kool.buffers.Collections.Aggregates.reduce

Parameters

operation

function that takes current accumulator value and an element, and calculates the next accumulator value.