純粋関数型言語Concurent Clean
■ このスレッドは過去ログ倉庫に格納されています
0188デフォルトの名無しさん
2005/10/25(火) 23:17:03foldrWithReadline:: !(String a-> a) a !*File -> (a, *File)
foldrWithReadline proc knil file
#! (end,file) = fend file
| end = (knil, file)
#! (line, file) = freadline file
# (lines , file) = foldrWithReadline proc knil file
= ((proc (trimNewline line) lines), file)
foldrWithReader:: !(*File->(Bool,a,*File)) !(a b->b) b !*File -> (b, *File)
foldrWithReader reader proc knil file
#! (ok, token, file) = reader file
| not ok = (knil, file)
# (tokens , file) = foldrWithReader reader proc knil file
= ((proc token tokens), file)
foldrWithReadChar:: !(Char a-> a) !a !*File -> (a, *File)
foldrWithReadChar x y z = foldrWithReader freadc x y z
readFile :: !String *World -> ([String],*World)
readFile path wld = callWithInputFile path
(\x -> abort ("readFile :: " +++ path ))
(foldrWithReadline (\x y -> [x:y]) []) wld
readFileChar :: !String *World -> ([Char],*World)
readFileChar path wld = callWithInputFile path
(\x -> abort ("readFileChar :: " +++ path))
(foldrWithReadChar (\x y -> [x:y]) []) wld
■ このスレッドは過去ログ倉庫に格納されています