The REPL

A good way to get to know this system is to start with Clojure’s interactive programming environment, the Read Eval Print Loop, or REPL.

You know what a REPL is: a user of the REPL types some code. The REPL reads it in, turning it from a string into another data structure. That data structure is then evaluated to produce a value, which is printed. Finally, the REPL loops back to the beginning, waiting for new input.

You will find instructions for installing a REPL in Chapter 20, Clojure’s Exceptional Handling of Exceptions.

Let’s start off in the classic style by running “hello, world” in the REPL.

 => (println "hello, world")
 hello, world
 nil

If we’d like to add two numbers together, the syntax looks the same. Here, we ...

Get Functional Programming: A PragPub Anthology 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.