Sorry for another stupid question. Not proud of asking these kind questions .
I am sure it is stupid, however I searched google and stack overflow but still not sure how to do this.
The question is very simply,
using Printf
@printf("%9.3f %9.3f %9.3f %9.3f",1.0,2.0,3.0,4.0)
I need to display 4 numbers from 1.0 to 4.0 for example. Now, do I have to manually put %9.3f for four times in the fmt?
In Fortran I can do things like
4(9.3f)
So that I do not need to put 9.3f 4 times.
In Julia, or in printf, is there a similar way so that I do not need to repeat 9.3f 4 times?
Thank you so much! That is so cool!
Nice, this should be way to go!
This is similar with what is in Fortran, like, I can define a format first (with variable in it), like
A workaround I used to use for this before discovering the solution suggested by @heliosdrm. This is probably not suggested, but is very convenient for code interpolation in macros.
Yes, thatās true. It would be nice to have a macro which achieves similar functionality, i.e just evaluates only the code inside $(...). I donāt think that would be hard. Atleast for me, I have needed to use @eval for this purpose frequently for evaluating some code which I need to pass to another macro. But I havenāt seen this proposed anywhere.
Note that if you are writing tabular data you can just use CSV.jl and Dataframes. Writing and reading text files can be quite complicated (lots of corner cases) so itās better to use a library that is well tested.