O'Reilly logo

Clojure Programming Cookbook by Nicolas Modrzyk, Makoto Hashimoto

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using functional programming style

In this recipe, we will show you how to define and use anonymous functions and have functions as arguments and return functions. Using the concepts and techniques described here correctly provides higher abstraction.

Getting ready

This section does not make use of any external library, so you can just start a REPL and be ready.

How to do it...

First, let's see some functions take functional arguments.

Functions taking functions as their arguments

Clojure functions such as map and reduce can take functions as arguments.

map

The map function has already been seen in the previous chapters. The map function takes a function as the first argument, applies it to all elements of collection arguments, and returns a lazy sequence. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required