« [Ruby] ActiveRecord の find | トップページ | [本] 返した本 »

2006年8月12日 (土)

[Comp] ふつける(7.9 練習問題)


if式を使うようじゃまだまだですかね。



main = do cs <- getContents
putStr $ unlines $ concatMap fold (lines cs)
fold :: String -> [String]
fold str = let (s, rest) = splitAt 60 str
in if null rest then [s] else s : fold rest


if 式を使っていない解答例の方が読みやすいですね。


|

« [Ruby] ActiveRecord の find | トップページ | [本] 返した本 »

コメント

この記事へのコメントは終了しました。

トラックバック


この記事へのトラックバック一覧です: [Comp] ふつける(7.9 練習問題):

« [Ruby] ActiveRecord の find | トップページ | [本] 返した本 »