Re: A style question
- From: Wade Humeniuk <whumeniu+anti+spam@xxxxxxxxx>
- Date: Wed, 28 Feb 2007 03:02:30 GMT
Wade Humeniuk wrote:
Another style
(defun fbv (n)
(or (remove nil (list (and (zerop (mod n 3)) "Fizz")
(and (zerop (mod n 5)) "Buzz")))
(list n)))
(defun fizz-buzz (n)
(loop for i from 1 to n do (format t "~{~A~}~%" (fbv i))))
Wade
And with a few macros,
;--- Part of a handy kit
(defun prinl (list)
(map nil 'princ list)
(terpri))
(defmacro over (i start end &body body)
`(loop for ,i from ,start to ,end do ,@body))
(defmacro no-nulls (&body tests)
`(remove nil (list ,@tests)))
;----------------------------------------------
(defun fbv (n)
(or (no-nulls
(and (zerop (mod n 3)) "Fizz")
(and (zerop (mod n 5)) "Buzz"))
(list n)))
(defun fizz-buzz (n)
(over i 1 n (prinl (fbv i))))
Wade
.
- References:
- A style question
- From: job-271842874
- Re: A style question
- From: Wade Humeniuk
- A style question
- Prev by Date: Re: Effeciency of any predicate
- Next by Date: Re: is a relational db a god tool or not really worth it?
- Previous by thread: Re: A style question
- Next by thread: Re: A style question
- Index(es):
Relevant Pages
|