Re: A style question
- From: Richard M Kreuter <kreuter@xxxxxxxxx>
- Date: Wed, 28 Feb 2007 12:38:48 -0500
"Tim Bradshaw" <tfb+google@xxxxxxxx> writes:
On Feb 28, 3:40 pm, Richard M Kreuter <kreu...@xxxxxxxxx> wrote:
(dotimes (i 100)
(format t "~[~[FizzBuzz~:;Fizz~]~:;~[Buzz~:;~D~]~]~%" (mod i 3) (mod i 5) i))
Best I could do on one cup of coffee.
Good, but you'd get extra points for avoiding the explicit FizzBuzz in
there. Off the top of my head I think:
(format t "~&~[Fizz~;~]~[Buzz~;~D~]~%" (mod i 3) (mod i 5) i). But
I'd have to check, and it's not really squiggly enough.
I think you mean "~&~[Fizz~:;~]~[Buzz~:;~D~]~%" right?
Something like that was my first hunch, but it will print the integer
next to Fizz when (and (zerop (mod i 3)) (plusp (mod i 5))),
* (let ((i 6)) (format t "~&~[Fizz~:;~]~[Buzz~:;~D~]~%" (mod i 3) (mod i 5) i))
-| Fizz6
=> NIL
* (let ((i 9)) (format t "~&~[Fizz~:;~]~[Buzz~:;~D~]~%" (mod i 3) (mod i 5) i))
-| Fizz9
=> NIL
Here's one that avoids the explicit FizzBuzz, and adds /seven/
squiggles to my first stab:
(dotimes (i 100)
(format t "~[~[~3@*~A~A~:;~3@*~A~]~:;~[~4@*~A~:;~D~]~]~%"
(mod i 3) (mod i 5) i "Fizz" "Buzz"))
Better?
--
RmK
.
- Follow-Ups:
- Re: A style question
- From: Tim Bradshaw
- Re: A style question
- From: John Thingstad
- 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
- A style question
- Prev by Date: Re: A style question
- 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):