Haskell Quiz/FizzBuzz/Solution Acontorer: Difference between revisions

From HaskellWiki
New page: FizzBuzz <haskell> -- This implementation is designed to demonstrate extensibility, -- as the list of tags can be easily edited, loaded from a file, et...
 
No edit summary
Line 2: Line 2:


<haskell>
<haskell>
-- a FizzBuzz (and FizzBuzzBaz) solution by Aaron Contorer.
-- This implementation is designed to demonstrate extensibility,
-- This implementation is designed to demonstrate extensibility,
-- as the list of tags can be easily edited, loaded from a file, etc.
-- as the list of tags can be easily edited, loaded from a file, etc.

Revision as of 22:22, 7 October 2012


-- a FizzBuzz (and FizzBuzzBaz) solution by Aaron Contorer.
-- This implementation is designed to demonstrate extensibility,
-- as the list of tags can be easily edited, loaded from a file, etc.

fizzBuzz i = if null desc then show i else desc where 
   desc = concat [label | (j,label) <- tags, 0 == rem i j]
   tags = [ (3,"Fizz"), (5,"Buzz"), (7,"Baz") ]
   
main = mapM_ (putStrLn . fizzBuzz) [1..120]