🎉 Black Friday Sale! Save 30% when you subscribe today.

Composable Randomness

Episode #30 • Sep 17, 2018 • Subscriber-Only

Randomness is a topic that may not seem so functional, but it gives us a wonderful opportunity to explore composition. After a survey of what randomness looks like in Swift today, we’ll build a complex set of random APIs from just a single unit.

Collection
Composable Randomness
Composable Randomness
Locked

Unlock This Episode

Our Free plan includes 1 subscriber-only episode of your choice, plus weekly updates from our newsletter.

Sign in with GitHub

Introduction

Today we’re going to start a series of episodes on a topic that might not seem very functional: randomness.

Swift 4.2 introduces much-needed library support for randomness, which was designed from the ground up to be easier and safer to use than the existing available APIs. We’re going to take a look at some of the problems it was designed to solve and explore how we may have solved them in an alternate, functional API rooted in composition.

We’ll start by taking quick look at the original problems.

Randomness in Swift: numbers


References

  • Random Zalgo Generator
    Brandon Williams • Nov 20, 2018

    We apply the ideas of composable randomness to build a random Zalgo generator, which is a way to apply gitchy artifacts to a string by adding strange unicode characters to it. It shows that we can start with very simple, small pieces and then compose them together to create a really complicated machine.

Downloads

Get started with our free plan

Our free plan includes 1 subscriber-only episode of your choice, access to 64 free episodes with transcripts and code samples, and weekly updates from our newsletter.

View plans and pricing