プログラミング言語論Ⅱ 期末テスト 解答例(2025 年度)

Ⅰ
(1)
main = do all<- getContents
          putStr (unlines (map processLine (lines all)))

processLine ln = let ws = words ln
                     ws2 = oddOnly ws
                   in unwords ws2
    where oddOnly []     = []
          oddOnly (x1:x2:xs) = x1 : oddOnly xs
          oddOnly (x:[]) = [x]
(2)
main = do all<- getContents
          putStr (unlines (map processLine (lines all)))

processLine ln = let ws  = words ln
                     ws1 = filter beginWithVowel ws
                   in unwords ws1
    where beginWithVowel []     = True
          beginWithVowel (x:xs) = x `elem` "aiueoAIUEO"