Back on the Horse
November 25th, 2008
Nothing quite like a meme to get you back into the swing of things. Following up on the programming meme from Eric Florenzano, I’ve decided to implement the challenge in the modicum of lisp I know.
Code
(defun prompt-read (prompt)
(format *query-io* "~a: " prompt)
(force-output *query-io*)
(read-line *query-io*))
(defvar name (prompt-read "name"))
(defvar age (parse-integer (prompt-read "age")))
(loop for i from 1 to age do (format t "~{~a: Hello, ~a~}~%" (list i name)))
Results
; SLIME 2008-11-02
CL-USER> (defun prompt-read (prompt)
(format *query-io* "~a: " prompt)
(force-output *query-io*)
(read-line *query-io*))
PROMPT-READ
(defvar name (prompt-read "name"))
(defvar age (parse-integer (prompt-read "age")))
(loop for i from 1 to age do (format t "~{~a: Hello, ~a~}~%" (list i name)))
name: Justin Lilly
age: 24
1:Hello, Justin Lilly
2:Hello, Justin Lilly
3:Hello, Justin Lilly
4:Hello, Justin Lilly
5:Hello, Justin Lilly
6:Hello, Justin Lilly
7:Hello, Justin Lilly
8:Hello, Justin Lilly
9:Hello, Justin Lilly
10:Hello, Justin Lilly
11:Hello, Justin Lilly
12:Hello, Justin Lilly
13:Hello, Justin Lilly
14:Hello, Justin Lilly
15:Hello, Justin Lilly
16:Hello, Justin Lilly
17:Hello, Justin Lilly
18:Hello, Justin Lilly
19:Hello, Justin Lilly
20:Hello, Justin Lilly
21:Hello, Justin Lilly
22:Hello, Justin Lilly
23:Hello, Justin Lilly
24:Hello, Justin Lilly
NIL
CL-USER>
Also check out a few others who’ve done the meme:
Comments are disabled. If that bothers you, please contact me on twitter at @justinlilly and let me know.