Working with External Libraries
Libraries are packaged programs that are ready to be used in other projects. External libraries are libraries that come from other developers. In Clojure, examples of such libraries include Ring, an HTTP library; clojure.java-time
, a library for time and date manipulation; and hiccup
, a library for writing HTML code using Clojure-style syntax.
Most projects will require developers to use existing code packaged as libraries. This is a good thing. We do not want to write code over and over again if the problem at hand has been already solved and someone has created a library for it that we can use.
In this section, we will use the clojure.Java-time
library to display the current time.
Exercise 8.11: Using an External Library in a Leiningen Project
The aim of this exercise is to show you how to add a library to a Leiningen project and demonstrate how this library is used in code:
- The first thing to do is add a dependency to the
time...