Skip to content

Instantly share code, notes, and snippets.

@stripe-q
Last active May 24, 2016 09:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stripe-q/3575c5c264b54a0149aa5aa714bb90bb to your computer and use it in GitHub Desktop.
Save stripe-q/3575c5c264b54a0149aa5aa714bb90bb to your computer and use it in GitHub Desktop.
myAction.hs -> n 을 입력받고, n 줄만큼의 문자열을 입력받아 이를 공백으로 연결하여 출력한다.
main = do
n <- readLn :: IO Int
a <- sequence . replicate n $ getLine
putStrLn . unwords $ a
-- do 가 아닌 모나드 연산자를 이용한 결합.
main' = (readLn :: IO Int) >>= (\n -> (sequence . replicate n $ getLine) >>= (\a -> puStrLn . unwords $ a))
-- sequnce . replicate n = replicateM n
import Control.Monad
main = (readLn :: IO Int) >>= (\n -> replicateM n getLine >>= (\a -> putStrLn $ unwords a))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment