This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Thanks to @kimwallmark for teaching me `maybe` and showing me how a single lookup. | |
| -- I had the brilliant idea of using `snd`, even though I dislike the name. :) | |
| fizzbuzz :: Integer -> String | |
| fizzbuzz n = maybe (show n) snd $ classify n | |
| where | |
| classify n = find (\(m, _) -> n `mod` m == 0) [(15, "Fizzbuzz"), (5, "Buzz"), (3, "Fizz")] |