Re: A style question
- From: Tim Bradshaw <tfb@xxxxxxxx>
- Date: Wed, 28 Feb 2007 19:27:41 +0000
On 2007-02-28 17:38:48 +0000, Richard M Kreuter <kreuter@xxxxxxxxx> said:
I think you mean "~&~[Fizz~:;~]~[Buzz~:;~D~]~%" right?
Probably, yes.
(dotimes (i 100)
(format t "~[~[~3@*~A~A~:;~3@*~A~]~:;~[~4@*~A~:;~D~]~]~%"
(mod i 3) (mod i 5) i "Fizz" "Buzz"))
Really good, yes. Almost impossible to work out what it does. The perfectionist in me would insist on
"~&~[~[~3@*~A~A~:;~3@*~A~]~:;~[~4@*~A~:;~D~]~]~%"
- you do actually want that so you know it always starts a line properly, apart from being an extra bit of squigglines. But that's trivial compared to the main drag of it.
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 think I may be too rusty to write this, but something like:
(defun fb (n)
((lambda (c p)
(funcall c c p 1)
(lambda (c p i)
(or (> i n)
(funcall p c p i)))
(lambda (c p i)
(format t "~[~[~3@*~A~A~:;~3@*~A~]~:;~[~4@*~A~:;~D~]~]~%"
(mod i 3) (mod i 5) i "Fizz" "Buzz")
(funcall c c p (1+ i))))))
(I should point out that I don't have a CL on the system I'm writing this.)
--tim
.
- Follow-Ups:
- Re: A style question
- From: Harald Hanche-Olsen
- Re: A style question
- From: Richard M Kreuter
- Re: A style question
- References:
- A style question
- From: job-271842874
- Re: A style question
- From: Frank Buss
- Re: A style question
- From: job-271842874
- Re: A style question
- From: Tim Bradshaw
- Re: A style question
- From: Richard M Kreuter
- Re: A style question
- From: Tim Bradshaw
- Re: A style question
- From: Richard M Kreuter
- A style question
- Prev by Date: Re: A style question
- Next by Date: Re: A style question
- Previous by thread: Re: A style question
- Next by thread: Re: A style question
- Index(es):
Relevant Pages
|