Navigating Clojure Libraries

Clojure code is packaged in libraries. Each Clojure library belongs to a namespace, which is analogous to a Java package. You can load a Clojure library with require:

 (require quoted-namespace-symbol)

When you require a library named, Clojure looks for a file named clojure/java/io.clj on the CLASSPATH. Try it:

 user=>​ (require ​'​)
 -> nil

The leading single quote () is required, and it quotes the library name. The nil returned indicates success. While you’re at it, test that you can load the sample code for this chapter, examples.introduction:

 user=>​ (require ​'examples.introduction​)
 -> nil

The examples.introduction library includes an implementation of the Fibonacci ...

Get Programming Clojure, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.