I am very new to Julia language, so I started to read the documentation and all builtin functions. Now, I am learning one github project for my work. Since I am more comfortable with Python, I tried to translate Julia’s code to python by my understanding, but I got a few weird syntaxes that I didn’t understand and I got stuck with them. Can anyone point me out the meaning of those syntaxes? Thanks in advance!
syntax that I don’t understand
those julia code line that I didn’t understand because I didn’t find them either in documentations.
var1 = Tuple{Integer, Vector}[]
here we declare object var 1, what’s real example for that? what’s python version?
also if X::Matrix, n::Int
, then what’s the meaning of ?
in the below? How should I code this in python?
K = [( i >= j ? dot(view(X,:,i), view(X,:,j)) : 0.0 )::Float64 for i=1:n, j=1:n]
I am not sure meaning of ->
in below:
for i=1:n
id_i = find(x -> x[1] == i, var1)
xi_i_list = map(x -> x[2], var1[id_i])
lastly, I just don’t understand the meaning of .>
in below:
act= zeros(100)
alpha = zeros(10)
for i=1:100
idx = find(x::Tuple{Integer, Vector} -> x[1] == i, var1)
act[i] = sum(alpha[idx] .> 1e-3)
As a newbie, I am trying to understand the role of find()
, map()
. To the best, I wish I could write the above Julia code with Python. But I have a hard time understanding the code. Can anyone give possible interpretations and corresponding python codes for learning purposes? Thanks in advance!