Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,22 @@
defmodule Write_float_arrays do
def task(xs, ys, fname, precision\\[]) do
xprecision = Keyword.get(precision, :x, 2)
yprecision = Keyword.get(precision, :y, 3)
format = "~.#{xprecision}g\t~.#{yprecision}g~n"
File.open!(fname, [:write], fn file ->
Enum.zip(xs, ys)
|> Enum.each(fn {x, y} -> :io.fwrite file, format, [x, y] end)
end)
end
end
x = [1.0, 2.0, 3.0, 1.0e11]
y = for n <- x, do: :math.sqrt(n)
fname = "filename.txt"
Write_float_arrays.task(x, y, fname)
IO.puts File.read!(fname)
precision = [x: 3, y: 5]
Write_float_arrays.task(x, y, fname, precision)
IO.puts File.read!(fname)