stdlib: add flatten()

This commit is contained in:
Ilya Ryzhenkov
2015-01-13 19:49:12 +03:00
parent 1d4591d99c
commit 95d4accda7
5 changed files with 47 additions and 6 deletions
@@ -164,6 +164,11 @@ abstract class IterableTests<T : Iterable<String>>(val data: T, val empty: T) {
assertEquals(listOf(3, 3), lengths)
}
Test
fun flatten() {
assertEquals(listOf(0, 1, 2, 3, 0, 1, 2, 3), data.map { 0..it.length() }.flatten())
}
Test
fun mapIndexed() {
val shortened = data.mapIndexed {(index, value) -> value.substring(0..index) }