concept sequence in category kotlin

This is an excerpt from Manning's book Functional Programming with Kotlin.
Functional programming is an alternative style to the imperative that addresses the problems mentioned above. In this chapter we will be looking at a simple example where a piece of imperative code with side effects (we’ll understand what that means shortly) is transformed into the functional style by a sequence of refactoring steps. The eradication of these side effects is one of the core concepts behind functional programming, and so is one of the highlights of this chapter. We will understand the dangers these effects pose and see how to extract them from our code, bringing us back to the safe place of simplicity where we departed from when we initially set out on our journey.
The
sequenceandtraversecombinators should be pretty familiar to you by now, and your implementations of them from previous chapters are probably all very similar. Implement them once and for all onMonad<F>.

This is an excerpt from Manning's book The Joy of Kotlin.
The
constantsfunction produces the set of limit values (such asInt.MIN_VALUE,0andINT.MAX_VALUEfor integers). Most often, you’ll make it return an empty list. Therandomfunction returns a sequence of randomly created instances.
Write a package-level function called
sequencethat combines aList<Option<A>>into anOption<List<A>>. It’ll be aSome<List<A>>if all values in the original list areSomeinstances, or aNone<List<A>>if there is at least oneNonein the list. Here’s its signature: