いろんな言語で宿題スレ at TECH
[2ch|▼Menu]
300:デフォルトの名無しさん
09/06/26 19:32:49
>>298
-- Haskell

import IO
import Data.Char (isAlpha, toLower)
import Data.Maybe (fromJust)

main = do
fname <- getLine
h <- openFile fname ReadMode
phon <- readPhon h
str <- getLine
putStrLn $ t298 phon str
hClose h

readPhon :: Handle -> IO [(Char,String)]
readPhon h = hGetContents h >>= return . map parse . lines
where
parse :: String -> (Char,String)
parse (c:',':p) = (c,p)

t298 :: [(Char,String)] -> String -> String
t298 phon [] = []
t298 phon (x:xs) | isAlpha x = (fromJust $ lookup (toLower x) phon) ++ ' ' : t298 phon xs
| otherwise = x : t298 phon xs


次ページ
続きを表示
1を表示
最新レス表示
スレッドの検索
類似スレ一覧
話題のニュース
おまかせリスト
▼オプションを表示
暇つぶし2ch

4630日前に更新/314 KB
担当:undef