I started reading The Joy of Clojure, seems like a great book and I like its example code convention. I’m documenting it here because I’ll adopt it on my blog and I want to be able to link to it. I’ll call it the joyful Clojure example code convention.

A simple piece of Clojure code looks like this:

(* 2 10)

If you run it on the REPL it looks like this:

user> (* 2 10)
20

The first example, it’s just the code, with no return value, the second one, shows the return value, but when you have several lines it becomes cumbersome to copy and paste:

user> (* 2 10)
20
user> (* 2 11)
22
user> (* 2 12)
24

The Joy of Clojure code convention solves both problems by removing the prompt and leaving return values in comments:

(* 2 10)
;=> 20
(* 2 11)
;=> 22
(* 2 12)
;=> 24

Now you can copy and paste and still have the results.

If the snippet prints something, it will also be displayed but without the arrow, like this:

(println "Hello world")
; Hello world
;=> nil

You may also like:

If you want to work with me or hire me? Contact me

You can follow me or connect with me:

Or get new content delivered directly to your inbox.

Join 5,047 other subscribers

I wrote a book:

Stack of copies of How to Hire and Manage Remote Teams

How to Hire and Manage Remote Teams, where I distill all the techniques I’ve been using to build and manage distributed teams for the past 10 years.

I write about:

announcement blogging book book review book reviews books building Sano Business C# Clojure ClojureScript Common Lisp database Debian Esperanto Git ham radio history idea Java Kubuntu Lisp management Non-Fiction OpenID programming Python Radio Society of Great Britain Rails rant re-frame release Ruby Ruby on Rails Sano science science fiction security self-help Star Trek technology Ubuntu web Windows WordPress

I’ve been writing for a while:

Mastodon