May 2018
Beginner to intermediate
290 pages
6h 43m
English
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 ...
Read now
Unlock full access