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. ...
Get Clojure Programming Cookbook 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.