-- Quick hack by Charles Banas, 5/15/09 -- Generic function to test an arbitrary modulo of a number and -- return the specified string. mod' str m n = if ((n `mod` m) == 0) then str else [] -- Specializations for modulo 5 and 3, which return specific strings mod3 = mod' "fizz" 3 mod5 = mod' "buzz" 5 -- A "test" function to simplify the use of multiple modulo tests tester n = (mod3 n) ++ (mod5 n) -- Map the test onto a list of numbers, to return a list of strings fizzbuzz = map tester [1..100] -- Main function. main = do print fizzbuzz