News for hackers. Stuff that matters.
Re:Kotlin for Data Analysis by rbehrends on Wednesday August 28, 2024 @11:20PM (#41386949)
Like this?

  sequence { for (x in 0..<10) for (y in 0..<10) yield(x*y) }.toList()
Now, technically, Kotlin doesn't have list comprehensions, only the equivalent of generator expressions in Python, so you have to tack an extra `.toList()` on at the end if you want a list, but you can write pretty much any for comprehension in Python in a similar way in Kotlin.
Re:Kotlin for Data Analysis by robch on Thursday August 29, 2024 @11:10PM (#41397424)
You could also build the list directly.

  buildList { for (x in 0..<10) for (y in 0..<10) add(x*y) }