Chapter 4Functional Programming

Functional programming (FP) is a big topic, not to be learned in 21 days[21] or in a single chapter of a book. Nevertheless, you can reach a first level of effectiveness using lazy and recursive techniques in Clojure fairly quickly, and that is what we’ll accomplish this chapter.

We’ll start with a quick overview of FP terms and concepts and an introduction to the guidelines of Clojure FP that we’ll refer to throughout the chapter. Next we’ll experience the power of lazy sequences by working through a series of implementations of the Fibonacci numbers. As cool as lazy sequences are, you rarely need to construct them yourself, and we’ll see better ways to recast problems to solve them directly with the sequence ...

Get Programming Clojure, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.