Subject: Re: A style question
From: rpw3@rpw3.org (Rob Warnock)
Date: Wed, 28 Feb 2007 22:52:13 -0600
Newsgroups: comp.lang.lisp
Message-ID: <woWdnWlfqrlgxnvYnZ2dnUVZ_q6vnZ2d@speakeasy.net>
Ken Tilton  <kentilton@gmail.com> wrote:
+---------------
| ps. Me, I am not starting until we get the functional requirements 
| cleared up. k
+---------------

See my reply to <nallen05@gmail.com>'s MOD-free code-generating macro,
or take this instead:

    Macro DEF-FIZZ-BUZZ  -- Define a "fizz-buzz"-generating function

    Syntax:
    def-fizz-buzz fname alist ==> fname

    Arguments and Values:
    fname -- A symbol, the name of the function to be defined (as by DEFUN).

    alist -- an association list, whose keys are prime integers > 1
	     and whose values are strings.

    Description:

    DEF-FIZZ-BUZZ defines a function named FNAME of one argument,
    a positive integer. When called with an argument (say) N, FNAME
    will print each positive integer starting with 1 below N, followed
    by a newline, except that if any of the keys of the ALIST evenly
    divide the current integer, then the corresponding string value(s)
    of the key(s) dividing the current integer will be printed instead
    of the integer itself. Note: If multiple keys divide the current
    integer, all of the corresponding string values will be printed,
    in the same order as the elements of the ALIST. Only one copy
    of any string value will be printed for any current integer.

    Examples:

    (def-fizz-buzz 'fizz-buzz '((3 . "Fizz") (5 . "Buzz"))) ==> FIZZ-BUZZ

    (fizz-buzz 22)
    >> 1
    >> 2
    >> Fizz
    >> 4
    >> Buzz
    >> Fizz
    >> 7
    >> 8
    >> Fizz
    >> Buzz
    >> 11
    >> Fizz
    >> 13
    >> 14
    >> FizzBuzz
    >> 16
    >> 17
    >> Fizz
    >> 19
    >> Buzz
    >> Fizz
    >> 22
    ==> NIL

    (def-fizz-buzz 'very-fizzy
		   '((2 . "Burp") (3 . "Fizz") (5 . "Buzz") (7 . "Bang")))
    ==> VERY-FIZZY

    (very-fizzy 16)
    >> 1
    >> Burp
    >> Fizz
    >> Burp
    >> Buzz
    >> BurpFizz
    >> Bang
    >> Burp
    >> Fizz
    >> BurpBuzz
    >> 11
    >> BurpFizz
    >> 13
    >> BurpBang
    >> FizzBuzz
    >> Burp
    ==> NIL

There's your spec. Where's your code?  ;-}


-Rob

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