I participated briefly in the Advent of Code 2018. Every year, they post 31 coding puzzles, 2 per day. You have to solve them before you can proceed to next one. I wanted to post about what I learned. I’ve never participated before, and wanted to use it an excuse to force myself to use a Functional Programming language. I use Functional Programming concepts in my day job, but never had the opportunity to immerse myself, and force myself, to accomplish harder challenges in a pure FP language. It was doubly hard because the exercises are NOT what I do at my day job at all and are challenging. They were very hard in a fun way, though. Below I’ll cover the 6 exercises I did (I threw in the towel on Day 7), and explain some of the interesting nuances I found either with the exercise and thinking in FP… and thinking in Elm.
Chris Coyier, a famous web dev whose articles on CSS/HTML/design have helped even lowly me, has a super compelling video my colleague Steven Sacks shared with me. Chris covers the many facets of “what is a front end developer”, the identity crisis the term has, and it’s fascinating. Totally valid in what I’ve seen in the past 8 years.
Functional Programming is built around composing pure functions. Composing functions means taking all those useful functions you wrote and using them together to build more powerful functions, and even applications. This article will cover the 4 main ways to do that with synchronous code which includes the new pipeline operator. A future article will handle asynchronous options as well as dealing with partial applications and curried functions. If you’d like to play with the examples yourself, I have a Code Sandbox setup with basic and advanced examples.
A Partial Application is a function where some or all of the arguments are packed inside, ready to go and it’s just waiting for a few more before the main function is invoked. They’re like functions that have default arguments, but are pure functions with a fixed amount of parameters.
The following article and companion video playlist will cover what a partial application is and how it can be used for a more pure function option for default arguments. It’s assumed you know what pure functions are. We’ll cover:
basic function arguments
default arguments and how order can make them harder/easier to use
function currying with closures and show how the parameter order is reversed compared to default arguments
building partial applications to show how to make using default arguments pure