1
haskell.it로 작성된 완전한 기능의 프로그램은 명령 행 인수에 문제가 있습니다. 입력하는 경우 :haskell의 redact 프로그램에서 다중 인수
고양이 poem.txt |
그것은 단지 당신이
고양이 poem.txt를 작성하는 경우 단어 1
수정하는 절차를 밟 word3 단어 1의 word2을 편집하다 | 편집하다 "단어 1 word2 word3"그것은이 아마 내가 명령 줄 인수했던 실수의 일종입니다 ... 3 단어 수정하는 절차를 밟
는 ... 여기
module Main where
import System
import Data.Char
import Data.Bits
convertWord :: Eq a=> [a] -> String
convertWord = map (const '*')
lowercase :: [Char]->[Char]
lowercase ch = map toLower ch
redact :: String -> String -> String
redact text keywords = unlines(map unwords redactedtext)
where redactedtext = map processed text1
text1 = map words (lines text)
processed = map tobeconverted
keywords1 = words keywords
tobeconverted x | lowercase x `elem` map lowercase keywords1 = convertWord x
| otherwise = x
main = do
text <- getContents
(key:_) <- getArgs
let
result = redact text key
putStr (result)
정말 고마워, 그게 총체적인 감각을 만들었 어 ... 나는 그것을 바꿨다. – user1295012
그 답을 수락 한 것으로 표시해야합니다 :) –