What general tips do you have for golfing in Common Lisp? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to Common Lisp (e.g. "remove comments" is not an answer).

Please post one tip per answer.

  • \$\begingroup\$ Narrower version of Tips for golfing in Lisp. \$\endgroup\$
    – user48538
    Commented Aug 9, 2016 at 11:18
  • 2
    \$\begingroup\$ @zyabin101 right. I thought that since original topic didn't have too many answers, and Lisp itself is a huge family, I might as well ask for a specific language. \$\endgroup\$ Commented Aug 9, 2016 at 11:19

2 Answers 2


Use ' (quote) as synonym for "" for single words.

Quote stops evaluation of symbol, allowing you to e.g. print it. Note that the casing is dependant on *print-case* variable (most of the time it's in the upcase).

(print'yes) ; saved a byte!

Use the best looping construct for the job

Use looping constructs that are as short as possible - loop for is rarely the way to go:

  • (dotimes(i <number>)) to loop a certain number of times
  • (mapcan lambda list) to map a list
  • (mapcar lambda list) to map and flatten a list
  • (do((var1 initialvalue1 nextvalue1)(var2 initialvalue2 nextvalue2)...)((endcondition)returnvalue)) for more complex loops
  • (map'string body list) to map string -> string
  • (map nil body list) to iterate over a list

Not the answer you're looking for? Browse other questions tagged or ask your own question.