Anonymous user
File input/output: Difference between revisions
→{{header|Snabel}}
Line 2,526:
Reads the entire file into into a list of buffers before writing and returns number of bytes written.
<lang snabel>
let: q
'input.txt' rfile read {@q $1 push _} for
0 @q 'output.txt' rwfile
$1 _ &+ for
</lang>
Line 2,534 ⟶ 2,535:
<lang snabel>
func: do-write {(
rwfile
{_ yield1} for
)};
Line 2,540 ⟶ 2,541:
func: do-copy {
"Init queue and writer proc"
let: q
func: w @q fifo $1 do-write proc;
_ rfile read 0 $1 {
"Push to queue and run writer if incoming data"
+? {$ @q $2 push _ len $1 _ +
} for
"Run writer until done if data left in queue"
@q
};
|