- fold.hs
foldCol = 61 main = do cs <- getContents putStr $ unlines $ map foldLineAt $ lines cs foldLineAt :: String -> String foldLineAt cs = case snd (splitAt foldCol cs) of [] -> cs (c1:cs1) -> if length cs1 >= (foldCol - 1) then foldLineAt cs1 else fst (splitAt foldCol cs) ++ "\n" ++ snd (splitAt foldCol cs)
どうもソースが汚いなぁ。もっと綺麗に書けるように練習しないと。どうも条件分岐の処理がへたくそな気がする。