Re: A style question



Tim Bradshaw <tfb@xxxxxxxx> writes:
On 2007-02-28 17:38:48 +0000, Richard M Kreuter <kreuter@xxxxxxxxx> said:

I'm unhappy about the explicit looping however. I can see two
solutions to this:

* something really gratuitous involving GO
* something equally gratuitous involving a lot of LAMBDAs.

I'm sorry, but here's the best I can do for now.

(unwind-protect
(prog ((i 0) mod3 mod5)
(declare (special i mod3 mod5))
(setf (symbol-function 'cl-user::format-eval)
(lambda (stream thing colon atsign)
(declare (ignore stream colon atsign))
(handler-bind ((warning #'muffle-warning))
(eval thing))))
(setf mod3 (mod i 3)
mod5 (mod i 5))
format
(ecase
(catch 'go
(format
t
"~&~[~[~3@*~A~A~:;~3@*~A~*~]~:;~[~4@*~A~:;~D~2*~]~]~%~/CL-USER::FORMAT-EVAL/"
mod3 mod5 i "Fizz" "Buzz"
'(progn
(incf i)
(setf
mod3 (mod i 3)
mod5 (mod i 5))
(if (> i 100)
(throw 'go 'quit)
(throw 'go 'format)))))
(format (go format))
(quit (go quit)))
quit nil)
(fmakunbound 'cl-user::format-eval))

I know, it doesn't have enough LAMBDAs.

--
RmK
.