Capturing and displaying results from within Julia

I have looked everywhere for it, so I am putting it here for the weary traveler;

Question: How can I get the full output of a variable to a file from a julia script?

i.e.

#script.jl
y = f(x)
y > out.txt

      

+3


source to share


1 answer


The answer is here:

https://github.com/JuliaLang/IJulia.jl/issues/455 If you want to display the output then:

show(STDOUT, "text/plain", x)

      

If you want to pipe the output to a file, then:



x=rand(Float32, 32,32)
f = open("log.txt", "w")
    write(f, string(x))
close(f)

      

And for a larger or more beautiful exit

x = rand(Float32, 1028,1028);
f = open("log.txt", "w");
writedlm(f, x);
close(f);

      

+3


source







All Articles