Write float arrays to a text file: Difference between revisions
Content added Content deleted
(→{{header|zkl}}: rewrite) |
m (→{{header|zkl}}: remove bad idea) |
||
Line 1,537: | Line 1,537: | ||
xprecision,yprecision := 3,5; |
xprecision,yprecision := 3,5; |
||
writeFloatArraysToFile("floatArray.txt", xs,xprecision, ys,yprecision);</lang> |
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}} |
{{out}} |
||
<pre> |
<pre> |