https://kotlinlang.org logo
Title
l

LastExceed

03/28/2021, 12:45 PM
I'm getting into functional programming, here is my implementation of conways game of life. I feel like the content of main() doesnt really fit the functional paradigm, but i can't figure out a better way that doesn't risk stack overflow (unless I use stuff like tailrec which feels like cheating). I tried looking at other peoples implementations online, but they all seem ridiculously complicated. any advice ?
e

ephemient

03/28/2021, 3:05 PM
generateSequence(initialUniverse) { it.computeNextGeneration() }
    .onEachIndexed { i, _ ->
        if (i != 0) usleep(200_000)
    }
    .forEach { universe ->
        universe.print()
    }
l

LastExceed

03/28/2021, 6:53 PM
thanks!