3 ms·
(format nil "I have~{ ~(~A~)~#[~;, and~:;,~]~}." '(red green blue black white yellow))
by PieSquared 18y ago
(format nil "I have~{ ~(~A~)~#[~;, and~:;,~]~}." '(red green blue black white yellow))
- begemot 18y agoa = ["red", "green", "blue", "black", "white", "yellow"]; "I have %s and %s" % (", ".join(a[:-1]), a[-1]) Well almost...
- gruseom 18y agoThat's sort of cheating, since you dropped out of CL into the format mini-language.
- PieSquared 18y agoYou're right of course. I was also considering showing off the loop macro. That one actually wouldn't have been cheating, since it shows off macros (A pretty nifty and central feature of Lisp) (loop for x from 1 to 10 as x-sqr = (* x x) collect x-sqr) Or something like that.