Introduction

Functional programming has its own set of patterns that have evolved out of the functional style.

These patterns rely heavily on immutability. For instance, Pattern 12, Tail Recursion, shows a general purpose replacement for iteration that doesn’t rely on a mutable counter, while Pattern 15, Chain of Operations, shows how to work with immutable data by chaining transformations on an immutable data structure.

Another theme in these patterns is the use of higher-order functions as a primary unit of composition. This dovetails nicely with the first theme, immutability and transformation of immutable data. By using higher-order functions we can easily do these transformations, as we demonstrate in Pattern 14, Filter-Map-Reduce.

One final theme we’ll explore is the ability of functional languages to be adapted to create little languages that solve particular problems. This type of programming has spread well outside the functional style, but it started with the Lisp tradition that Clojure carries on. We’ll see it in Pattern 12, Tail Recursion, and Pattern 21, Domain-Specific Language.

Let’s take a look at our first pattern, Tail Recursion.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.216.96.94