| William Bland ( @ 2007-07-25 09:08:00 |
| Entry tags: | clutu, computers, lisp |
FORMAT is awesome
I love Common Lisp's FORMAT.
Here's a snippet of code from the crossword site I've been working on. This gets invoked after you press the "check" button and clutu has identified any words that are filled-in wrong:
(push (list "clutu" (if wrong (format nil "~{~#[~;~a~;~a and ~a~:;~@{~a~#[~;, and ~:;, ~]~}~]~} ~[is~:;are~] wrong" (reverse wrong) (1- (length wrong))) "everything is ok")) (chat-of game))
It produces output (in the chat pane) like "clutu: 13 across and 4 down are wrong".
I think I started by grabbing an example from Peter's book.
Format is one of the things that looked scary when I first came to Common Lisp, but now I hate to do without when I'm using some lesser language.