Jump to content

Write float arrays to a text file: Difference between revisions

m
m (→‎{{header|zkl}}: remove bad idea)
m (→‎{{header|Sidef}}: updated code)
Line 1,461:
{{trans|Perl 6}}
<lang ruby>func writedat(filename, x, y, x_precision=3, y_precision=5) {
var fh = File.new(filename).open_w;
 
 
MultiArray.newfor a,b in (x, ~Z y).each { |x, y|
fh.printf("%.*g\t%.*g\n", x_precision, xa, y_precision, yb);
}
 
 
fh.close;
}
 
 
var x = [1, 2, 3, 1e11];
var y = x».map{.sqrt»();}
 
 
writedat('sqrt.dat', x, y);</lang>
{{out}}
<pre>
2,747

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.