A quine is a program which produces its own sourcecode as its output. Typically, the trick is to use a format string with a call to
a print
or printf
function. Since lisps can easily treat sourcecode as any other data, writting a quine in lisp is not as
mind-bending an excersise as in other languages (see the examples here).
Additionally, access to anonymous functions in Clojure makes it easy to get the recursion required for a quine.
Writing a quine initially seems a daunting task, but once it's broken down a bit, it becomes surprisingly easy. Armed with lambdas and syntax quoting, all we need to do is write a function which returns the argument passed to it wrapped in lambda syntax, and applied to the argument wrapped in syntax quoting.