The following is the code.
v=[2,3,4]
v[[true for i in v]]
It would return a 3-element Array{Int64,1}, [2,3,4]. It looks a bit strange to me. Originally, I thought it would return a matrix. I was wondering, how do you understand it?
The following is the code.
v=[2,3,4]
v[[true for i in v]]
It would return a 3-element Array{Int64,1}, [2,3,4]. It looks a bit strange to me. Originally, I thought it would return a matrix. I was wondering, how do you understand it?
Aren’t you just indexing with a boolean mask? I.e. you are doing
v[[true, true, true]]
So selecting all elements in v
A boolean-array index always yields a vector, and I don’t see how it could be different.
Otherwise, what shape should this be:
v = [1 2; 3 4]
v[v.>1]