Skip to content

Instantly share code, notes, and snippets.

@purcell purcell/FizzBuzz.hs

Created Oct 29, 2014
Embed
What would you like to do?
fizzbuzz
module FizzBuzz where
data FizzBuzz = Fizz | Buzz | FizzBuzz deriving Show
fizzbuzz :: Integral a => a -> Either FizzBuzz a
fizzbuzz n = case (n `rem` 3, n `rem` 5) of
(0, 0) -> Left FizzBuzz
(0, _) -> Left Fizz
(_, 0) -> Left Buzz
_ -> Right n
outputs :: [String]
outputs = map (either show show . fizzbuzz) [1..50]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.