In the Wild
And now we have the answer to the opening question of this chapter: the thing that makes Clojure a functional programming language is that you do basic things by writing functions and you do more sophisticated things by treating the functions as values—values that you can pass around and call and combine.
Possibly the best demonstration of the functions are values idea can be found inside the machinery of defn itself. defn is just a thin layer over def and fn. So when you define a new function with defn, perhaps this:
| (defn say-welcome [what] |
| (println "Welcome to" what "!")) |
what gets evaluated is something like this:
| (def say-welcome |
| (fn [what] (println "Welcome to" what "!"))) |
As the name suggests, defn is ...
Get Getting Clojure 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.