Skip to content

Clojure


Warning: array_merge(): Expected parameter 2 to be an array, bool given in /home/customer/www/inchkeithconsulting.com/public_html/wp-content/plugins/urvanov-syntax-highlighter/class-urvanov-syntax-highlighter.php on line 275

To start Clojure we can spin up the REPL with the command ‘clj’

And then to get back to the command line its as simple as CTRL-C

We can also run a clojure script from the command line. We therefore typically store our code in files with the .clj extension. We can then load a lisp file via a command line parameter

In Clojure, we can use comments to add documentation to the code inline

Hello, World! ( because it’s mandatory )

And that’s it, that’s Lisp ( or Clojure ) in a nutshell. An expression is a list which the Clojure interpreter evaluates and the result displayed. Each expression is a list surrounded by (). In this instance the expression calls the function println ( which displays text to the console ) with the parameter “Hello, World!”.

Documentation

Before we get into the details of programming in Lisp, the Clojure REPL provides some useful functions to get documentation and help on the libraries and functions you will be using.

Basic Numbers, Types and Operations

Variables

Functions

For more information on regular expressions, see the crib sheet Regular Expressions

Clojure Core Libraries

Clojure ships with a large number of core libraries. They can be found at https://clojuredocs.org/core-library