Jump to content

Write float arrays to a text file: Difference between revisions

m
→‎{{header|zkl}}: remove bad idea
m (→‎{{header|zkl}}: remove bad idea)
Line 1,537:
xprecision,yprecision := 3,5;
writeFloatArraysToFile("floatArray.txt", xs,xprecision, ys,yprecision);</lang>
Note that closing the file is redundant as the garbage collector will also do that, which means you could write the function as:
<lang zkl>fcn writeFloatArraysToFile2(filename, xs,xprecision, ys,yprecision){
fmt:="%%.%dg\t%%.%dg".fmt(xprecision,yprecision).fmt; // "%.3g\t%.5g".fmt
xs.zip(ys).pump(File(filename,"w").writeln, Void.Xplode, fmt);
}</lang>
 
{{out}}
<pre>
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.