2024-05-03 08:48:29 +02:00
|
|
|
builtin ["os.file", "base"];
|
|
|
|
|
|
|
|
readInt=func(fh){
|
2024-06-09 16:01:47 +02:00
|
|
|
line=fileRead(fh);
|
2024-05-03 08:48:29 +02:00
|
|
|
line ? [nil] {nil} :: {int(line)}
|
|
|
|
};
|
|
|
|
|
|
|
|
ds={
|
|
|
|
"init":func(filename){
|
2024-06-09 16:01:47 +02:00
|
|
|
fh=fileOpen(filename);
|
2024-05-03 08:48:29 +02:00
|
|
|
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){
|
2024-06-09 16:01:47 +02:00
|
|
|
fileClose(fh)
|
2024-05-03 08:48:29 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//;f=$(ds, "int.list")
|
|
|
|
/*
|
|
|
|
;f++
|
|
|
|
;f++
|
|
|
|
;f++
|
|
|
|
*/
|
|
|
|
//;add(f)
|