First, I guess you meant y[1, 1] = 0? I get an error if I use y [1. 1] = 0.
Julia has space sensitive syntax in some contexts, notable inside brackets [].
Some examples:
julia> max(1, 2)
2
julia> max (1, 2)
2
julia> [max(1, 2)]
1-element Array{Int64,1}:
2
julia> [max (1, 2)]
1x2 Array{Any,2}:
max (1,2)
julia> [1 + 2]
1-element Array{Int64,1}:
3
julia> [1 +2]
1x2 Array{Int64,2}:
1 2
In your first example, the call to findfirst in
x_filt [j, 1] = y [j, findfirst (y [j, :])]
is interpreted as two space-separated items, findfirst and (y [j, :])]. Julia then complains that they are separated by a space and not a comma.
In your second example, you were able to circumvent this since the call to findfirst in
temp = findfirst (y [j, :])
is no longer in a space sensitive context.
I would recommend that when writing Julia code, you should never put a space between the function name and parenthesis ( in a function call or the variable and bracket [ in indexing, because the code will be treated differently in space sensitive contexts. E.g., your first example without the extra spaces
for j=1:d
x_filt[j, 1] = y[j, findfirst(y[j, :])]
end
works fine (provided that you define d and x_filt appropriately first).