nice one - here is basically the same (I did not care about the prompt) in Haskell:
module FizzBuzz where import Data.Function ((&)) import Data.Maybe (fromMaybe) import Data.Monoid ((<>)) fizzBuzz :: Int -> Int -> [String] fizzBuzz from to = fizzBuzzer <$> [from .. to] ---------------------------------------------------------------------- fizzBuzzer :: Int -> String fizzBuzzer n = Nothing <> ifMultiple 3 "Fizz" n <> ifMultiple 5 "Buzz" n & nIfEmpty n ifMultiple :: Int -> String -> Int -> Maybe String ifMultiple d out n | n `mod` d == 0 = Just out | otherwise = Nothing nIfEmpty :: Int -> Maybe String -> String nIfEmpty n = fromMaybe (show n)
isn't it nice how that just translates
PS: the n there should probably be refactored into a Reader-Monad :P
n
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
nice one - here is basically the same (I did not care about the prompt) in Haskell:
isn't it nice how that just translates
PS: the
n
there should probably be refactored into a Reader-Monad :P