Re: A style question
- From: job-271842874@xxxxxxxxxxxxxx
- Date: Tue, 27 Feb 2007 23:31:13 -0500
justinhj wrote:
(defun multiple(x n)
(= 0 (mod x n)))
(defun output-multiple(x n str)
(if (and (multiple x n) (princ str))
1
0))
(defun fizzbuzz(n)
(loop for x from 1 to n do
(if (> (+ (output-multiple x 3 "fizz") (output-multiple x 5
"buzz")) 0)
(format t "~%"))))
Hmm.. this doesn't seem to work.
[1]> (defun multiple(x n)
(= 0 (mod x n)))
MULTIPLE
[2]>
(defun output-multiple(x n str)
(if (and (multiple x n) (princ str))
1
0))
OUTPUT-MULTIPLE
[3]>
(defun fizzbuzz(n)
(loop for x from 1 to n do
(if (> (+ (output-multiple x 3 "fizz") (output-multiple x 5
"buzz")) 0)
(format t "~%"))))
FIZZBUZZ
[4]> (fizzbuzz 12)
fizz
buzz
fizz
fizz
buzz
fizz
NIL
[5]>
.
- Follow-Ups:
- Re: A style question
- From: justinhj
- Re: A style question
- References:
- A style question
- From: job-271842874
- Re: A style question
- From: job-271842874
- Re: A style question
- From: justinhj
- A style question
- Prev by Date: Re: A style question
- Next by Date: Re: Lisp Syntax - functions versus data
- Previous by thread: Re: A style question
- Next by thread: Re: A style question
- Index(es):
Relevant Pages
|