Subject: Re: A style question
From: rpw3@rpw3.org (Rob Warnock)
Date: Wed, 28 Feb 2007 21:55:58 -0600
Newsgroups: comp.lang.lisp
Message-ID: <zfSdnauewaJT03vYnZ2dnUVZ_vqpnZ2d@speakeasy.net>
Pillsy <pillsbury@gmail.com> wrote:
+---------------
| Ken Tilton <kentil...@gmail.com> wrote:
| > Tim Bradshaw wrote:
| [...]
| > > Incidentally, I'm deeply disappointed in the quality of answers in
| > > this thread.  In the elder days there would have been at least a few
| > > followups showing how to do this in the proper "FORMAT string
| > > indistinguishable from line noise" way.
| 
| > Oh, absolutely, long overdue in this thread. Is this going to become a
| > lost art? The village elders need to step up, methinks. I started
| > playing with it, but I am just an elder, not a Lisp elder. Screams for a
| > nested thingy, yes?
| 
| Well, if you're going to throw down the gauntlet like that, I'm
| just going to have to respond in the hopes of provoking someone
| into besting my wimpy attempt.
| 
| (apply #'format t "~@{ ~2@{~D ~}~^~*Fizz ~D ~*Buzz~
|                        ~*Fizz ~2@{~D ~} ~*Buzz ~D ~*Fizz~
|                        ~2@{~D ~} ~*FizzBuzz ~%~}"
|        (loop :for i :from 1 to 100 :collect i))
+---------------

Very cute!! Except... it doesn't give correct answers:

     1 2 Fizz 4 BuzzFizz 7 8  Buzz 10 Fizz12 13  FizzBuzz 
     15 16 Fizz 18 BuzzFizz 21 22  Buzz 24 Fizz26 27  FizzBuzz 
     29 30 Fizz 32 BuzzFizz 35 36  Buzz 38 Fizz40 41  FizzBuzz 
     43 44 Fizz 46 BuzzFizz 49 50  Buzz 52 Fizz54 55  FizzBuzz 
     57 58 Fizz 60 BuzzFizz 63 64  Buzz 66 Fizz68 69  FizzBuzz 
     71 72 Fizz 74 BuzzFizz 77 78  Buzz 80 Fizz82 83  FizzBuzz 
     85 86 Fizz 88 BuzzFizz 91 92  Buzz 94 Fizz96 97  FizzBuzz 
     99 100 

- Those "BuzzFizz" should probably be "Buzz Fizz" (missing space).
- Missing spaces elsewhere, too.
- 9 is divisible by 3, not 5.
- 11 is *not* divisible by either 3 or 5.
- 12 *is* divisible by 3.
- 14 is *not* divisible by 3.
- Etc. etc...


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607