Fix foldRight implementation for iterables

This commit is contained in:
Alexander Zolotov
2012-06-15 13:22:47 +04:00
parent ef1946eee2
commit ae00b0bb15
15 changed files with 35 additions and 21 deletions
@@ -145,7 +145,7 @@ public inline fun <T> Array<T>.fold(initial: T, operation: (T, T) -> T): T {
*
* @includeFunctionBody ../../test/CollectionTest.kt foldRight
*/
public inline fun <T> Array<T>.foldRight(initial: T, operation: (T, T) -> T): T = reverse().fold(initial, operation)
public inline fun <T> Array<T>.foldRight(initial: T, operation: (T, T) -> T): T = reverse().fold(initial, {x, y -> operation(y, x)})
/**
* Groups the elements in the collection into a new [[Map]] using the supplied *toKey* function to calculate the key to group the elements by
@@ -145,7 +145,7 @@ public inline fun BooleanArray.fold(initial: Boolean, operation: (Boolean, Boole
*
* @includeFunctionBody ../../test/CollectionTest.kt foldRight
*/
public inline fun BooleanArray.foldRight(initial: Boolean, operation: (Boolean, Boolean) -> Boolean): Boolean = reverse().fold(initial, operation)
public inline fun BooleanArray.foldRight(initial: Boolean, operation: (Boolean, Boolean) -> Boolean): Boolean = reverse().fold(initial, {x, y -> operation(y, x)})
/**
* Groups the elements in the collection into a new [[Map]] using the supplied *toKey* function to calculate the key to group the elements by
@@ -145,7 +145,7 @@ public inline fun ByteArray.fold(initial: Byte, operation: (Byte, Byte) -> Byte)
*
* @includeFunctionBody ../../test/CollectionTest.kt foldRight
*/
public inline fun ByteArray.foldRight(initial: Byte, operation: (Byte, Byte) -> Byte): Byte = reverse().fold(initial, operation)
public inline fun ByteArray.foldRight(initial: Byte, operation: (Byte, Byte) -> Byte): Byte = reverse().fold(initial, {x, y -> operation(y, x)})
/**
* Groups the elements in the collection into a new [[Map]] using the supplied *toKey* function to calculate the key to group the elements by
@@ -145,7 +145,7 @@ public inline fun CharArray.fold(initial: Char, operation: (Char, Char) -> Char)
*
* @includeFunctionBody ../../test/CollectionTest.kt foldRight
*/
public inline fun CharArray.foldRight(initial: Char, operation: (Char, Char) -> Char): Char = reverse().fold(initial, operation)
public inline fun CharArray.foldRight(initial: Char, operation: (Char, Char) -> Char): Char = reverse().fold(initial, {x, y -> operation(y, x)})
/**
* Groups the elements in the collection into a new [[Map]] using the supplied *toKey* function to calculate the key to group the elements by
@@ -145,7 +145,7 @@ public inline fun DoubleArray.fold(initial: Double, operation: (Double, Double)
*
* @includeFunctionBody ../../test/CollectionTest.kt foldRight
*/
public inline fun DoubleArray.foldRight(initial: Double, operation: (Double, Double) -> Double): Double = reverse().fold(initial, operation)
public inline fun DoubleArray.foldRight(initial: Double, operation: (Double, Double) -> Double): Double = reverse().fold(initial, {x, y -> operation(y, x)})
/**
* Groups the elements in the collection into a new [[Map]] using the supplied *toKey* function to calculate the key to group the elements by
@@ -145,7 +145,7 @@ public inline fun FloatArray.fold(initial: Float, operation: (Float, Float) -> F
*
* @includeFunctionBody ../../test/CollectionTest.kt foldRight
*/
public inline fun FloatArray.foldRight(initial: Float, operation: (Float, Float) -> Float): Float = reverse().fold(initial, operation)
public inline fun FloatArray.foldRight(initial: Float, operation: (Float, Float) -> Float): Float = reverse().fold(initial, {x, y -> operation(y, x)})
/**
* Groups the elements in the collection into a new [[Map]] using the supplied *toKey* function to calculate the key to group the elements by
@@ -145,7 +145,7 @@ public inline fun IntArray.fold(initial: Int, operation: (Int, Int) -> Int): Int
*
* @includeFunctionBody ../../test/CollectionTest.kt foldRight
*/
public inline fun IntArray.foldRight(initial: Int, operation: (Int, Int) -> Int): Int = reverse().fold(initial, operation)
public inline fun IntArray.foldRight(initial: Int, operation: (Int, Int) -> Int): Int = reverse().fold(initial, {x, y -> operation(y, x)})
/**
* Groups the elements in the collection into a new [[Map]] using the supplied *toKey* function to calculate the key to group the elements by
@@ -143,7 +143,7 @@ public inline fun <T> java.util.Iterator<T>.fold(initial: T, operation: (T, T) -
*
* @includeFunctionBody ../../test/CollectionTest.kt foldRight
*/
public inline fun <T> java.util.Iterator<T>.foldRight(initial: T, operation: (T, T) -> T): T = reverse().fold(initial, operation)
public inline fun <T> java.util.Iterator<T>.foldRight(initial: T, operation: (T, T) -> T): T = reverse().fold(initial, {x, y -> operation(y, x)})
/**
* Groups the elements in the collection into a new [[Map]] using the supplied *toKey* function to calculate the key to group the elements by
@@ -145,7 +145,7 @@ public inline fun LongArray.fold(initial: Long, operation: (Long, Long) -> Long)
*
* @includeFunctionBody ../../test/CollectionTest.kt foldRight
*/
public inline fun LongArray.foldRight(initial: Long, operation: (Long, Long) -> Long): Long = reverse().fold(initial, operation)
public inline fun LongArray.foldRight(initial: Long, operation: (Long, Long) -> Long): Long = reverse().fold(initial, {x, y -> operation(y, x)})
/**
* Groups the elements in the collection into a new [[Map]] using the supplied *toKey* function to calculate the key to group the elements by
@@ -145,7 +145,7 @@ public inline fun ShortArray.fold(initial: Short, operation: (Short, Short) -> S
*
* @includeFunctionBody ../../test/CollectionTest.kt foldRight
*/
public inline fun ShortArray.foldRight(initial: Short, operation: (Short, Short) -> Short): Short = reverse().fold(initial, operation)
public inline fun ShortArray.foldRight(initial: Short, operation: (Short, Short) -> Short): Short = reverse().fold(initial, {x, y -> operation(y, x)})
/**
* Groups the elements in the collection into a new [[Map]] using the supplied *toKey* function to calculate the key to group the elements by
@@ -145,7 +145,7 @@ public inline fun <T> Iterable<T>.fold(initial: T, operation: (T, T) -> T): T {
*
* @includeFunctionBody ../../test/CollectionTest.kt foldRight
*/
public inline fun <T> Iterable<T>.foldRight(initial: T, operation: (T, T) -> T): T = reverse().fold(initial, operation)
public inline fun <T> Iterable<T>.foldRight(initial: T, operation: (T, T) -> T): T = reverse().fold(initial, {x, y -> operation(y, x)})
/**
* Groups the elements in the collection into a new [[Map]] using the supplied *toKey* function to calculate the key to group the elements by