concept corecursive in category functional programming

This is an excerpt from Manning's book Functional Programming with Kotlin.
The
unfoldfunction is an example of what’s sometimes called a corecursive function. Whereas a recursive function consumes data, a corecursive function produces data. And whereas recursive functions terminate by recursing on smaller inputs, corecursive functions need not terminate so long as they remain productive, which just means that we can always evaluate more of the result in a finite amount of time. Theunfoldfunction is productive as long asfterminates, since we just need to run the functionfone more time to generate the next element of theStream. Corecursion is also sometimes called guarded recursion, and productivity is also sometimes called cotermination. These terms aren’t that important to our discussion, but you’ll hear them used sometimes in the context of functional programming. If you’re curious to learn where they come from and understand some of the deeper connections, follow the references in the chapter notes.