Hi,

Is an assigment inside a comprehension a "good practice" e.g. I want to 
fill in columns of a temporary matrix as follows:

tmp = zeros(10,10)

# this is flawless
for i in 1:10
 tmp[1:i,i] = rand(i)
end

# this is a neat one line expression but I wonder whether it does not 
silently allocate result outside of the comprehension
[ tmp[1:i,i] = rand(i) for i in 1:10 ]
# e.g. here "x" becomes a vector of vectors ...
x = [ tmp[1:i,i] = rand(i) for i in 1:10 ]

Thanks for an advice,
Jan
 

Reply via email to