For when you want to define your own custom matcher logic for each word in your custom fizzbuzzer. Still lets you put a single number in for 'divides by' logic.
(defmacrodefine-fizzbuzzer(name&bodypairs)(let((ps(clean-argspairs)))`(defun,name(n)(let((resultnil))(dolist(p',ps)(let((test-passed?(funcall(eval(firstp))n)))(whentest-passed?(push(secondp)result))))(if(nullresult)(write-to-stringn)(apply#'concatenate'string(nreverseresult)))))))(defunclean-args(pairs)(mapcar#'clean-pairpairs))(defunclean-pair(pair)(cond((typep(firstpair)'integer)(list'#'(lambda(n)(dividesn(firstpair)))(secondpair)))((eq(caarpair)'function)pair)(t(error"first element of pair must be either an integer or a function"))))(defunprime?(n)"evaluates to t when n is prime. Highly inefficient"(loopforxfrom2to(roundn2)never(dividesnx)))(defunhas-a-nine-in-it?(n)"does the decimal representation of this number have a 9 in it?"(some#'(lambda(c)(char=c#\9))(write-to-stringn)))(define-fizzbuzzerfizz-buzz(3"Fizz")(5"Buzz"))(define-fizzbuzzerfazz-bazz(#'prime?"Fazz")(#'has-a-nine-in-it?"Bazz"))
Here's some fun from the world of Common Lisp
Inoffensive version
Offensive FizzBuzz Builder Macro
For when you want to define your own custom fizzbuzzer. Nice and easy to extend.
Most Offensive Macrogeddon Too Hot for TV Version
For when you want to define your own custom matcher logic for each word in your custom fizzbuzzer. Still lets you put a single number in for 'divides by' logic.
Bring on the parentheses!