Re: [julia-users] Printf() of a variable number of arguments

2015-07-23 Thread Ismael VC
help? @sprintf INFO: Loading help data... Base.@sprintf(%Fmt, args...) Return @printf formatted output as string. julia s = @sprintf this is a %s test this is a test julia println(s) this is a test That is because `@sprintf` returns a string which you haven't printed. El miƩrcoles, 22 de

Re: [julia-users] Printf() of a variable number of arguments

2015-07-23 Thread Tero Frondelius
Thanks, it makes sense now. I actually read the documentation earlier, but didn't understand it. Now with the example it's very clear. On Thursday, July 23, 2015 at 3:56:39 PM UTC+3, Ismael VC wrote: help? @sprintf INFO: Loading help data... Base.@sprintf(%Fmt, args...) Return @printf

Re: [julia-users] Printf() of a variable number of arguments

2015-07-23 Thread Tero Frondelius
https://github.com/JuliaLang/julia/pull/12279 On Thursday, July 23, 2015 at 9:55:48 PM UTC+3, Ismael VC wrote: You are welcome, if you think this needs some clarification you could try to edit the manual for the good of everyone else! Cheers. On Thu, Jul 23, 2015 at 8:26 AM, Tero

Re: [julia-users] Printf() of a variable number of arguments

2015-07-23 Thread Ismael VC
You are welcome, if you think this needs some clarification you could try to edit the manual for the good of everyone else! Cheers. On Thu, Jul 23, 2015 at 8:26 AM, Tero Frondelius tero.frondel...@gmail.com wrote: Thanks, it makes sense now. I actually read the documentation earlier, but

Re: [julia-users] Printf() of a variable number of arguments

2015-07-22 Thread Tero Frondelius
I'm trying to learn macros. Can you help me to get this working? Currently the error is that arr is not defined. Probably an obvious mistake, but I just don't get hang of it. macro Write(arr) @eval begin for i in arr @sprintf(%12.6f\n,i) end end end a =

Re: [julia-users] Printf() of a variable number of arguments

2015-07-22 Thread Tero Frondelius
Thanks. My real error was to use @sprintf macro, thus a follow up question, why this isn't printing anything: macro Write(arr) quote for i in $arr @sprintf(%12.6f\n,i) end end end a = 1e5*rand(10) @Write a This is purely for learning purposes. This was simple enough

Re: [julia-users] Printf() of a variable number of arguments

2015-07-22 Thread Ismael VC
You forgot to interpolate the expression with `$`: julia macro write(arr) quote for i in $arr @printf(%12.6f\n,i) end end end julia a = 1e5*rand(10) 10-element Array{Float64,1}: 46310.6 25130.5 30710.8 82089.6

Re: [julia-users] Printf() of a variable number of arguments

2015-07-22 Thread Dominique Orban
I wrote this some time ago for my own projects. It's reasonably fast: https://gist.github.com/dpo/11000433

Re: [julia-users] Printf() of a variable number of arguments

2015-07-14 Thread Ferran Mazzanti
Thanks for the info. Actually my question comes from old fortran style, where I can write something of the form Write(1,'1000f12.6') a where a is an array. The string inside the write function says I can print 1000 doubkes in 12 characters with 6 decimals. So the string is a constant literal,

Re: [julia-users] Printf() of a variable number of arguments

2015-07-14 Thread Kaj Wiik
Would this work for you: julia a = 1e5*rand(1000) julia for i in a @printf(%12.6f\n, i) end 74708.038385 71244.774457 5057.229038 3761.297034 ... Remember that loops are fast in Julia... Kaj On Tuesday, July 14, 2015 at 9:14:37 AM UTC+3, Ferran Mazzanti wrote: Thanks for the

Re: [julia-users] Printf() of a variable number of arguments

2015-07-14 Thread Ferran Mazzanti
Yes thanks, I knew already looped solutions :) I was looking for somethin' compact as in the fortran statement above, though. It makes things more *neat*, if there's any such thing. On Tuesday, July 14, 2015 at 12:08:59 PM UTC+2, Kaj Wiik wrote: Would this work for you: julia a =

Re: [julia-users] Printf() of a variable number of arguments

2015-07-14 Thread elextr
You could just use a macro to take the format and the array and let it write the messy loop for you. On Tuesday, July 14, 2015 at 8:39:44 PM UTC+10, Ferran Mazzanti wrote: Yes thanks, I knew already looped solutions :) I was looking for somethin' compact as in the fortran statement above,

[julia-users] Printf() of a variable number of arguments

2015-07-06 Thread Ferran Mazzanti
Hi, I have a simple question: is it possible to feed printf() a list with a variable number of arguments? Specifically I want to print a formatted list of numbers contained in an arrary, but I can't tell in advance how many elements does the array contain. Is there an easy way to do that, or

Re: [julia-users] Printf() of a variable number of arguments

2015-07-06 Thread Yichao Yu
On Mon, Jul 6, 2015 at 6:47 PM, Ferran Mazzanti ferran.mazza...@gmail.com wrote: Hi, I have a simple question: is it possible to feed printf() a list with a variable number of arguments? Specifically I want to print a formatted list of numbers contained in an arrary, but I can't tell in