Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Main where
- import Control.Applicative
- import Data.Maybe
- f :: Integer -> String -> Integer -> Maybe String
- f k s i = if i `rem` k == 0 then Just s else Nothing
- opts = [f 15 "FizzBuzz", f 3 "Fizz", f 5 "Buzz"]
- fizzBuzz n = fromJust $ foldr1 (<|>) $ (opts <*> pure n) <> [Just $ show n]
- main = mapM_ (putStrLn . fizzBuzz) [1..1000]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement