RosettaCodeData/Task/Write-float-arrays-to-a-text-file/Sidef/write-float-arrays-to-a-text-file.sidef
2017-09-25 22:28:19 +02:00

14 lines
294 B
Text
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

func writedat(filename, x, y, x_precision=3, y_precision=5) {
var fh = File(filename).open_w
 
for a,b in (x ~Z y) {
fh.printf("%.*g\t%.*g\n", x_precision, a, y_precision, b)
}
 
fh.close
}
 
var x = [1, 2, 3, 1e11]
var y = x.map{.sqrt}
 
writedat('sqrt.dat', x, y)