I am new to Julia Lang. I am coming from the background of Matlab.
In Matlab, when pressing whos
command I will get all variables in the current scope; and also, I can store them in another variable like x=whos;
Is there such commands exists in Julia? Example code in Matlab:
>> a=3; >> b=4; >> whos Variables in the current scope: Attr Name Size Bytes Class ==== ==== ==== ===== ===== a 1x1 8 double b 1x1 8 double prefix 1x16 16 char Total is 18 elements using 32 bytes.
Variables A variable, in Julia, is a name associated (or bound) to a value. It's useful when you want to store a value (that you obtained after some math, for example) for later use.
Unlike the shell PATH variable, empty entries in JULIA_LOAD_PATH are expanded to the default value of LOAD_PATH, ["@", "@v#.#", "@stdlib"] when populating LOAD_PATH. This allows easy appending, prepending, etc. of the load path value in shell scripts regardless of whether JULIA_LOAD_PATH is already set or not.
The absolute path of the directory containing the Julia executable, which sets the global variable Sys.BINDIR. If $JULIA_BINDIR is not set, then Julia determines the value Sys.BINDIR at run-time. by default. The global variable Base.DATAROOTDIR determines a relative path from Sys.BINDIR to the data directory associated with Julia. Then the path
The current value of the same environment variable can be determined by evaluating ENV ["JULIA_EDITOR"]. The environment variables that Julia uses generally start with JULIA.
An Update:
whos()
... is not working either in iJulia or at the command prompt in Julia-1.0.0.
It is working in Julia-0.6.4, though.
On the other hand,
varinfo()
....prints information about the exported global variables in a module. For Example,
julia-1.0> varinfo() name size summary –––––––––––––––– ––––––––––– ––––––––––––––––––––––––––––––– Base Module Core Module InteractiveUtils 154.271 KiB Module Main Module PyPlot 781.872 KiB Module ans 50.323 KiB Plots.Plot{Plots.PyPlotBackend} myrepl 0 bytes typeof(myrepl) x 88 bytes 1×6 Array{Int64,2} y 0 bytes typeof(y)
Hope, this is found useful.
You can use Julia's whos
functions just like that Matlab command.
julia> whos() Base Module Core Module Main Module ans Nothing julia> x = 5 5 julia> whos() Base Module Core Module Main Module ans Int64 x Int64
Any modules (packages/libraries) you import into your local scope (using using
) will also show up in the list (as Module
s, like Base, Core, and Main above).
Additionally, you can ask about names exported by Modules. Base
is the module containing the standard library.
julia> whos(Base) ! Function != Function !== Function $ Function % Function & Function * Function + Function .... (lots and lots more)
Considering that that result scrolls way off my screen, you can understand why you'd want to filter the results. For that you can use Regexes. (For more info on Julia's regexes, see this manual section)
julia> whos(r"M") Main Module julia> whos(Base, r"Match"i) DimensionMismatch DataType RegexMatch DataType each_match Function eachmatch Function ismatch Function match Function matchall Function
I wasn't aware of the whos
function before you asked, so thanks for helping me learn something new too. :)
Julia issue #3393 on github is about adding memory sizes to the whos
output. It also references making whos
return a value rather than just printing the information out.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With