Lighttable is simple IDE to get started with Clojure.
Emacs offers more extensive power features and is written in Lisp.
lein repl to enter REPL
CTRL+d to exit REPL
user=> (defn average [numbers] (/ (apply + numbers) (count numbers))) average
(average [60 80 100 400])// returns 160
All Clojure code is made up of expressions, each of which evaluates to a single value.
Lists in Lisps are often called s-expressions or sexprs—short for symbolic expressions due to the significance of symbols in identifying the values to be used in calls denoted by such lists.
Clojure call expressions follow one simple rule: the first value in a list is the operator, the remainder are parameters to that operator.
Clojure code is composed of literal representations of its own data structures and atomic values. This characteristic is formally called homoiconicity or more casually, code-as-data.
In practical terms, the direct correspondence between code and data means that the Clojure code you write in the REPL or in a text source file isn’t text at all: you are programming using Clojure data structure literals. Recall the simple averaging function from Example 1-2:
(defn average [numbers] (/ (apply + numbers) (count numbers)))
This isn’t just a bunch of text that is somehow transformed into a function definition through the operation of a black box; this is a list data structure that contains four values: the symbol defn, the symbol average, a vector data structure containing the symbol numbers, and another list that comprises the function’s body. Evaluating that list data structure is what defines the function.
The Clojure reader produces data structures from the text we write to program.