RosettaCodeData/Task/Write-float-arrays-to-a-text-file/Pluto/write-float-arrays-to-a-text-file.pluto
2026-04-30 12:34:36 -04:00

10 lines
298 B
Text

local x = {1, 2, 3, 1e11}
local y = {1, 1.4142135623730951, 1.7320508075688772, 316227.76601683791}
local xprec = 3
local yprec = 5
local file = io.open("filename.txt", "w+")
for i = 1, #x do
local s = string.format($"%0.{xprec}g\t%0.{yprec}g\n", x[i], y[i])
file:write(s)
end
file:close()