January 2014
Intermediate to advanced
232 pages
5h 11m
English
Clojure allows creation of functions without having to name them. Such functions are referred to as lambda expressions. These functions can be defined by using the fn special form. A special form is a type of a primitive that is evaluated using different rules than the standard primitives. Each special form can have a unique way to evaluate its arguments.
For example, if we wanted a function that prints a single argument, we could write the following:
| | (fn [arg] (println arg)) |
We could then pass a parameter to this function to be printed.
| | ((fn [arg] (println arg)) "hello") |
| | |
| | =>"hello" |
Clojure also provides syntactic sugar for defining anonymous functions using the # notation. The preceding function can ...
Read now
Unlock full access