I have a small question which is a little similar with not the same as
and
Here is the thing, I can manually input 1.0, 2.0, 3.0, 4.0, and print them in one line and in a file called fileout.txt, here is the code,
s = Printf.Format(string("%f"^4))
io = open("fileout.txt", "w")
Printf.format(io, s, 1.0,2.0,3.0,4.0)
close(io)
Now, if I have an array A,
A = [1.0, 2.0, 3.0, 4.0]
I was hoping that Printf.format is smart enough to do,
Printf.format(io, s, A)
However it cannot recognize A as a 4 element array and print each element as %f.
I wonder, is there a way to print A in one line with the format s?
Furthermore, if I have two arrays,
A = [1.0, 2.0, 3.0, 4.0]
B = [100.0, 200.0, 300.0, 400.0]
Now I want in a file say, fileout.txt, have B ± A element by element in one line, like,
100.0 +- 1.0 | 200.0 +- 2.0 | 300.0 +- 3.0 | 400.0 +- 4.0
What should I do?
Thank you very much in advance!