added static List.fill(size) { ... }

This commit is contained in:
sergeych committed 2026-04-03 21:15:41 +03:00
1 parent f1003f5b95
commit a7ab0d3905
9 files changed
+64 -9

No files matched your search

+7
View File
@@ -422,6 +422,13 @@ fun List<T>.sort(): void {
sortWith { a, b -> a <=> b }
}
/* Build a new list of `size` elements by calling `block(index)` for each index. */
static fun List<T>.fill(size: Int, block: (Int)->T): List<T> {
val result = List<T>()
for( i in 0..<size ) result += block(i)
result
}
/* Print this exception and its stack trace to standard output. */
fun Exception.printStackTrace(): void {
println(this)