Maybe this is what you want [y[:,1:2] hcat([y[:,j] for j=2:3]...)]
2014-04-02 8:53 GMT-04:00 Paweł Biernat <pawel.bier...@gmail.com>: > > Hi, > I am trying to construct a matrix (2d array) via the array comprehension and hcat like this > > y=[1 for i=1:3, j=1:3] > yy=hcat(y[:,1:2],[y[:,j] for j=2:3]) > > which fails with the following message > > ERROR: mismatch in dimension 1 > in cat_t at abstractarray.jl:680 > in hcat at abstractarray.jl:719 > in anonymous at no file > > I understand, that this message is caused by the difference in types > > julia> typeof(y[:,1:2]) > Array{Int64,2} > > julia> typeof([y[:,j] for j=2:3]) > Array{Any,1} > > > How can I inform Julia of that fact that the result of array comprehension is a 2d array? I tried to add some assertion to the list comprehension like this > hcat(y[:,1:2],Array{Int64,1}[y[:,j] for j=2:3]) > > but it still doesn't work. > > Alternatively, is there any other way to prepend/append/insert a column/row to the matrix y? -- Med venlig hilsen Andreas Noack Jensen