純粋関数型言語Concurent Cleanat TECH
純粋関数型言語Concurent Clean - 暇つぶし2ch39:デフォルトの名無しさん
04/02/10 00:44
>>1ではないのだが・・・
続き

getCsvData :: Int [Char] -> [Char]
getCsvData num [x:xs]    = getCsvData` num [x:xs]
where
    getCsvData` n [x:xs]
        | x == '\n'       = ['\n'] ++ getCsvData`     num xs
        | x == ','        = getCsvData`     (n-1) xs
        | n == 0          = [x] ++ getCsvData`     n   xs
        | otherwise        = getCsvData` n   xs
//    getCsvData`  0 [x:xs]   = [x] ++ getCsvData`     0   xs
     getCsvData` n []        = []

CharListWrite []    f = f
CharListWrite [c:cs] f = CharListWrite cs (fwritec c f)

CharFileCopy infile outfile = CharListWrite (CharListRead infile) outfile

CharListRead f
     | not readok = []
     | otherwise  = [char : CharListRead filepointer]
where
     (readok,char,filepointer) = sfreadc f
エラー処理は考えてません。
>>37はインデントがずれているので、適当に脳内補完しといてくれ。


次ページ
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch