#KT-2067 Fixed

This commit is contained in:
James Strachan
2012-05-23 09:46:15 +01:00
parent 939f0e9085
commit fc4340f0f7
21 changed files with 354 additions and 0 deletions
@@ -175,6 +175,20 @@ public inline fun FloatArray.makeString(separator: String = ", ", prefix: String
return buffer.toString().sure()
}
/** Returns a list containing the everything but the first elements that satisfy the given *predicate* */
public inline fun <L: List<Float>> FloatArray.dropWhileTo(result: L, predicate: (Float) -> Boolean) : L {
var start = true
for (element in this) {
if (start && predicate(element)) {
// ignore
} else {
start = false
result.add(element)
}
}
return result
}
/** Returns a list containing the first elements that satisfy the given *predicate* */
public inline fun <L: List<Float>> FloatArray.takeWhileTo(result: L, predicate: (Float) -> Boolean) : L {
for (element in this) if (predicate(element)) result.add(element) else break