Archive for the 'basics' Category

How can I find the type of a variable?

To find the type of a variable use the typeof function:


julia> a = 1
1

julia> b = [100,200,300]
3-element Array{Int64,1}:
100
200
300

julia> c = 1:10
1:10

julia> typeof(a)
Int64

julia> typeof(b)
Array{Int64,1}

julia> typeof(c)
UnitRange{Int64}

How can I get list of available Julia Packages?

q>How can I get a list and description of the packages available within Julia?

Use Pkg.available() to get the available packages as a list:


julia> Pkg.available()
749-element Array{AbstractString,1}:
"AbstractDomains"
"ActiveAppearanceModels"
"AffineTransforms"
"AmplNLWriter"
"AndorSIF"
"AnsiColor"
"AppConf"
"AppleAccelerate"
"ApproxFun"
"Arbiter"
"Arduino"
"ArgParse"
"ArrayViews"
"Arrowhead"
"ASCIIPlots"
"Atom"
"AudioIO"
"Augur"
"AutoHashEquals"
"Autoreload"
"AutoTypeParameters"
"AverageShiftedHistograms"
?
"WebSockets"
"WinRPM"
"Winston"
"WoodburyMatrices"
"Word2Vec"
"WordNet"
"WORLD"
"WorldBankData"
"WriteVTK"
"XClipboard"
"XGBoost"
"XSim"
"XSV"
"YAML"
"Yelp"
"Yeppp"
"YT"
"ZChop"
"ZipFile"
"Zlib"
"ZMQ"
"ZVSimulator"

How can I create an empty array?

q> How can I create a size zero array in Julia?

There are numerous methods of constructing an empty array in Julia:


julia> fill(0,0)
0-element Array{Int64,1}

julia> []
0-element Array{Any,1}

julia> ones(0)
0-element Array{Float64,1}

julia> zeros(0)
0-element Array{Float64,1}

julia> fill(0.,0)
0-element Array{Float64,1}