# A Little Clojure

DevFeed: [A Little Clojure](<https://devfeed.tech/articles/a-little-clojure-21785.md>)

Original publisher: [Read original article](<http://blog.cleancoder.com/uncle-bob/2020/04/06/ALittleClojure.html>)

Published: 2020-04-06T00:00:00Z

Content type: article

Language: en

Sources: [Robert C. Martin](<https://devfeed.tech/sources/robert-c-martin.md>), [The Clean Code Blog](<https://devfeed.tech/sources/the-clean-code-blog.md>)

Topics: [Clojure](<https://devfeed.tech/topics/clojure.md>), [Data structures](<https://devfeed.tech/topics/data-structures.md>)

Tags: [article](<https://devfeed.tech/tags/article.md>), [clojure](<https://devfeed.tech/tags/clojure.md>), [syntax](<https://devfeed.tech/tags/syntax.md>)

## AI overview

An introduction to Clojure covering list syntax, arithmetic and built-in functions, the REPL, quoting, and the implementation of lists as linked lists.

## Source excerpt

So let's learn just a little bit of clojure. This expression: (1 2) represents the list containing the integers 1 and 2 in that order. If you want an empty list, that's just (). And the list of the first five letters of the alphabet is just (\a \b \c \d \e). Now you know a lot about the syntax of clojure. Perhaps you think there's a lot missing. Well, there are a few things missing; but far fewer than you'd think. You might be wondering how you add two numbers. That's easy, that's just (+ 1 2). As it happens that's also just the list of the function named + followed by a 1 and a 2. You see, a function call is really just a list. The function is the first element of the list, and the arguments are just the other elements of that list. When you want to call a function, you simply invoke the list that represents that function call. There are quite a few built-in functions in clojure. For example there's +, -, *, and /. They do precisely what you'd think. Well, perhaps not precisely. (+ 1 2 3) evaluations to 6. (- 3 2 1) evaluates to zero. (* 2 3 4) evaluates to 24. And (/ 20 2 5) evaluates to 2. (- 5) evaluates to -5. (* 5) evaluates to 5. And, get ready for this, (/ 3) evaluates to 1/3. That last is the clojure syntax for the rational number one-third. (first 1 2 3) evaluates to 1, (second 1 2 3) evaluates to 2, and (last 1 2 3) evaluates to - you guessed it - 3. If you'd like to see this in action you'll need to start up a clojure REPL. You can google how to do that. The word REPL stands for Read, Evaluate, Print Loop. It's a very simple program that reads in an expression, evaluates that expression, prints the result of that expression, and then loops back to the read. If you start a REPL you'll get some kind of a prompt, perhaps like this user=>. Then you can type an expression and see it evaluated. Here are a few from my REPL user=> (+ 1 2 3 4) 10 user=> (- 5 6 7 8) -16 user=> (* 6 7 8) 336 user=> (/ 5 6 9) 5/54 If you try the expression at the very start of this