Execute HQ9+/Common Lisp: Difference between revisions

m
Fixed syntax highlighting.
(creating a page, not a category :\)
 
m (Fixed syntax highlighting.)
 
(4 intermediate revisions by 4 users not shown)
Line 1:
{{implementation|HQ9+}}{{collection|RCHQ9+}}
=={{header|Common Lisp}}==
 
The interpreter (in [[Common Lisp]]) accepts a string, treated as program text, or a pathname object, in which case the contents of the file are the program text.
 
<langsyntaxhighlight lang="lisp">(defun slurp (filespec)
"Return the contents of the file as a string."
(with-output-to-string (out)
Line 18:
with accumulator = 0
for c across src
do (condcase c
((char-equal c #\h) (write-line "Hello, world!" out))
((char-equal c #\q) (write-linestring src out))
((char-equal c #\+) (incf accumulator))
((char-equal c #\9)
(do ((n 99 (1- n))) ((zerop n))
(format out "~&~%~w bottle~:p of beer on the wall~%~
Line 34:
Go to the store and buy some more~%~
99 bottles of beer on the wall.~%")))
finally (return accumulator)))</langsyntaxhighlight>
9,482

edits