Become a member
to unlock all features

    Pull Many Random Numbers in a Single State ADT Transaction


    We have the ability to select a single random card from a pile of twelve cards, but we would like to pull a total of nine. Not only that, we would like to match the same transition functions we have been writing all along.

    Lucky for use there are three types of functions, or morphisms that we can use to get us everything we need. We use an anamorphism to expand our one function into a list of nine functions. Each of these functions are endomorphisms, so we can use the mreduce catamorphism with the Endo Monoid to fold them down into one function that we can use to get this action into our state transactions.