2010-04-02から1日間の記事一覧
プログラミング Haskell 6章 再帰関数 6.2リストに対する再帰 小さい順に並んでいるリストを先頭より比較し、リストの要素の値が挿入しようとする値と同じか大きくなったところに挿入される。 -- 挿入ソート insert :: Ord a => a -> [a] -> [a] insert x []…
Text.Regex.Posix の (=~) 関数を使った置換 import Text.Regex.Posix replace str old new | match == "" = str | otherwise = headStr ++ new ++ replace tailStr old new where (headStr,match,tailStr) = str =~ old ::(String,String,String) import Te…