O'Reilly logo

Mastering Clojure Macros by Colin Jones

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Clojure Koans

One helpful set of exercises for Clojure newcomers, the Clojure Koans,[26] has its code structure based on a macro called meditations that presents a boilerplate-free interface. Perhaps you’ve already tried these out as I suggested in the Introduction and wondered how it worked under the hood. The koans ask you to fill in the blanks in order to make each test pass:

apis/koans_1.clj
 
(meditations
 
"We shall contemplate truth by testing reality, via equality"
 
(​=​ __ true)
 
 
"To understand reality, we must compare our expectations against reality"
 
(​=​ __ (​+​ 1 1)))

But in the interface that the meditations macro presents, there are no tests! We just see some (more or less helpful) text vaguely describing an expression ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required