concept computing in category functional programming

appears as: computing
Functional Programming with Kotlin

This is an excerpt from Manning's book Functional Programming with Kotlin.

This method should generate a random Int. We’ll later define other functions in terms of nextInt. Rather than returning only the generated random number (as is done in kotlin.random.Random) and updating some internal state by mutating it in place, we return the random number and the new state, leaving the old state unmodified.[20] In effect, we separate the concern of computing what the next state is from the concern of communicating the new state to the rest of the program. No global mutable memory is being used—we simply return the next state back to the caller. This leaves the caller of nextInt in complete control of what to do with the new state. Note that we’re still encapsulating the state, in the sense that users of this API don’t know anything about the implementation of the random number generator itself.