Miscellaneous tips

Setting variables

There are multiple ways to set a variable:

All of the above methods also return the new value of the variable; multiple assignments return the last assigned value.

Special variables

' & `

Sometimes, it is possible to use quote as a variable, since 'foo is short for (quote foo). To use quote in an expression, use dotted pair notation. Lisp parses this notation like a list literal, so it must be followed by exactly one literal, identifier, or form.

; Example:
(dotimes(i 10)(format t"~d ~a~%"i"potato")) ; this
(dotimes'10(format t"~d ~a~%".'"potato"))   ; is equivalent to this,
(dotimes'10(format t"~d ~a~%".'"potato"())) ; but this will fail to compile

The above also holds for backquote, using .`. Backquote's intended use is also quite powerful for golfing, used for constructing and splatting/unrolling lists:

(list(+ x 10)1 2 3'(foo bar))
`(,(+ x 10)1 2 3(foo bar))
(append a b)
`(,@a,@b)

+, -, *, & /

The variables +, ++, and +++ (and their counterparts for / and *) store certain prior values of forms during the Lisp read-eval-print loop. Since submissions on code.golf are not run via interactive REPL, these values are never updated, but are set to specific values at the start of execution. Of particular use are * and /, which are both nil.

Reference