34 lines
469 B
Plaintext
34 lines
469 B
Plaintext
builtin ["os.file", "base"];
|
|
|
|
readInt=func(fh){
|
|
line=readFile(fh);
|
|
line ? [nil] {nil} :: {int(line)}
|
|
};
|
|
|
|
ds={
|
|
"init":func(filename){
|
|
fh=openFile(filename);
|
|
fh ? [nil] {nil} :: { @current=readInt(fh); @prev=@current };
|
|
fh
|
|
},
|
|
"current":func(){
|
|
prev
|
|
},
|
|
"next":func(fh){
|
|
current ?
|
|
[nil] {current}
|
|
:: {@prev=current; @current=readInt(fh) but current}
|
|
},
|
|
"clean":func(fh){
|
|
closeFile(fh)
|
|
}
|
|
}
|
|
|
|
//;f=$(ds, "int.list")
|
|
/*
|
|
;f++
|
|
;f++
|
|
;f++
|
|
*/
|
|
//;add(f)
|