You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
489 B
Haskell

module Main () where
import System.Environment
import Control.Monad
import Data.Maybe
hoppityfy :: Int -> Maybe String
hoppityfy n
| n `mod` 3 == 0 && n `mod` 5 == 0 = Just "Hop"
| n `mod` 3 == 0 = Just "Hoppity"
| n `mod` 5 == 0 = Just "Hophop"
| otherwise = Nothing
main :: IO ()
main = do
[filename] <- getArgs
content <- readFile filename
let n = (read content) :: Int
let hops = catMaybes . map hoppityfy $ [1 .. n]
forM_ hops $ \h -> putStr . (++ "\n") $ h