The CRC pattern in Elixir is a great way for functional programmers to organize code.

Learning Elixir: It’s All Reduce

Bruce Tate
11 min readFeb 5, 2021

The Missing Map for Learning FP

Groxio is now in our second year of teaching programmers to code functionally, and have fun doing it. Along the way, I’ve led more than a dozen groups of new and intermediate programmers through the treacherous waters of LiveView and OTP. In this post, I want to share with you a breakthrough I’ve found in these classrooms, a pattern called CRC, or construct-reduce-convert. Better yet, think construct |> reduce |> convert. It’s a simple story. Like all stories, this one has a beginning, a middle and an end.

You have doubtlessly noticed that Elixir, Groxio, the Jolly Roger, and treasure maps all share a big bright X. Sadly for you, dear reader, that means you’re going to have to wade through ten whole minutes of silly pirate wordplay. So, edge out onto this plank with me and we’ll stagger along these skinny, shivering timbers together.

A Treasure Map on a Number Line

It might surprise you that pirates love computers. After all, piracy is all about doing things the easy way. Let someone else suffer through mining and assembling all of that treasure, and slip in to reap the benefits at the end.

Computers, too, are about using machines to do the hard work so we can reap the benefits. So, let’s talk about one of the…

--

--

Bruce Tate

Bruce Tate is the founder of Groxio, a training and education company for programmers. He’s the author of more than a dozen books and an avid outdoor enthusiast