import Control.Applicative main = do ii <- fmap (fmap (read :: String -> Int) . words) . lines <$> getContents break ( ii == ("\n","\n")) print $ ii
複数行の入力を受け取って、
改行を二回入れたらブレイクしたいなって思い、
このようなコードを書いてみましたが
やっぱりそうは問屋が卸さないようです。
huku.hs:3:65: error: • Couldn't match expected type ‘((a0 -> Bool) -> [a0] -> ([a0], [a0])) -> Bool -> IO String’ with actual type ‘IO String’ • The function ‘getContents’ is applied to two arguments, but its type ‘IO String’ has none In the second argument of ‘(<$>)’, namely ‘getContents break (ii == ("\n", "\n"))’ In a stmt of a 'do' block: ii <- fmap (fmap (read :: String -> Int) . words) . lines <$> getContents break (ii == ("\n", "\n")) huku.hs:4:14: error: • Variable not in scope: ii :: ([Char], [Char]) • Perhaps you meant one of these: ‘id’ (imported from Prelude), ‘pi’ (imported from Prelude)
このように、親切ではありますが
たくさんのエラーが出てしまい
参ってしまいました。
助けてください。お願いします。
ありがとうございます。
改行二回のイメージは、二回連続でエンターを押した時です。
もう入力する値がない場合に、値を決定して
入力から抜けたいです。
回答2件
あなたの回答
tips
プレビュー