I had written something similar to Will Will, but the spec I read here says, that FizzBuzz should always cover [1..100], so my implementation was a bit different:
show' :: Int -> String
show' n
| fizz && buzz = "FizzBuzz"
| buzz = "Buzz"
| fizz = "Fizz"
| otherwise = show n
where fizz = mod n 3 == 0
buzz = mod n 5 == 0
fizzBuzz = [show' x | x <- [1..100]]
Will's idea about using where to cache the mod result was a nice idea IMHO.
I had written something similar to Will, but the spec I read here says, that FizzBuzz should always cover [1..100], so my implementation was a bit different:
show' :: Int -> String
show' n
| fizz && buzz = "FizzBuzz"
| buzz = "Buzz"
| fizz = "Fizz"
| otherwise = show n
where fizz = mod n 3 == 0
buzz = mod n 5 == 0
fizzBuzz = [show' x | x <- [1..100]]
Will's idea about using where to cache the mod result was a nice idea IMHO.
I had written something similar to Will, but the spec I read here says, that FizzBuzz should always cover [1..100], so my implementation was a bit different:
show' :: Int -> String
show' n
| fizz && buzz = "FizzBuzz"
| buzz = "Buzz"
| fizz = "Fizz"
| otherwise = show n
where fizz = mod n 3 == 0
buzz = mod n 5 == 0
fizzBuzz = [show' x | x <- [1..100]]
Will's idea about using where to cache the mod result was a nice idea IMHO.
I had written something similar to Will, but the spec I read here says, that FizzBuzz should always cover [1..100], so my implementation was a bit different:
show' :: Int -> String
show' n
| fizz && buzz = "FizzBuzz"
| buzz = "Buzz"
| fizz = "Fizz"
| otherwise = show n
where fizz = mod n 3 == 0
buzz = mod n 5 == 0
fizzBuzz = [show' x | x <- [1..100]]
Will's idea about using where to cache the mod result was a nice idea IMHO.