Karlo Lozovina
02/02/2022, 7:52 PMrepeat
that collects the output of the lambda it executes? shorter version of (1..times).map { ... }
ephemient
02/02/2022, 8:04 PMList(times) { ... }
Joffrey
02/02/2022, 8:04 PMList(n) { i -> ... }
Joffrey
02/02/2022, 8:05 PMephemient
02/02/2022, 8:05 PMgenerateSequence { ... }.take(times)
if you want it lazilyephemient
02/02/2022, 8:06 PMKarlo Lozovina
02/02/2022, 8:09 PMList(times)
Karlo Lozovina
02/02/2022, 8:10 PMrepeatMap
could be usefull...Joffrey
02/02/2022, 8:13 PMrepeatMap
be any different?Karlo Lozovina
02/02/2022, 8:14 PMRuckus
02/02/2022, 8:15 PMrepeatMap
is not shorter than List
...Karlo Lozovina
02/02/2022, 8:17 PMtodd.ginsberg
02/02/2022, 8:41 PMinfix fun <T> Int.times(fn: (Int) -> T): List<T> =
List(this) { fn(it) }
val list = 10 times {
"I am only kidding... or am I?"
}
ephemient
02/02/2022, 8:46 PMtodd.ginsberg
02/02/2022, 10:11 PM