It worked, thanks.
On Friday, October 16, 2015 at 6:38:50 PM UTC-3, Yichao Yu wrote: > > On Fri, Oct 16, 2015 at 5:35 PM, Thuener Silva <[email protected] > <javascript:>> wrote: > > I'm having this kind of problem in different situations. Another > example: > > > > julia> groups_1 = [Array((Int),0) for i=1:K] > > 5-element Array{Array{Int64,1},1}: > > [] > > [] > > [] > > [] > > [] > > > > julia> groups_1[size(groups_1[i],1) .!= 0 for i=1:size(groups_1,1)] > > ERROR: `Array{T,N}` has no method matching > > Array{T,N}(::Array{Array{Int64,1},1}, ::Int64) > > in anonymous at no file > > I don't think this kind of indexing is supported. > > > > > The workaround: > > julia> not_empty = [size(groups_1[i],1) .!= 0 for i=1:size(groups_1,1)] > > 5-element Array{Any,1}: > > false > > false > > false > > false > > false > > > > julia> not_empty = convert( Array{Bool,1}, not_empty) > > 5-element Array{Bool,1}: > > false > > false > > false > > false > > false > > You don't need the convert, not_empty = Bool[.....] should work > > > > > julia> groups_1 = groups_1[not_empty] > > 0-element Array{Array{Int64,1},1} > > > > On Friday, October 16, 2015 at 3:58:19 PM UTC-3, Steven G. Johnson > wrote: > >> > >> > >> > >> On Friday, October 16, 2015 at 1:55:19 PM UTC-4, Andras Niedermayer > wrote: > >>> > >>> You can also use `map`, which is better at type inference: > >>> > >>> julia> M=10 > >>> 10 > >>> > >>> julia> [[i] for i=1:M] > >>> 10-element Array{Any,1}: > >> > >> > >> As usual, type inference is much better if you don't run it in global > >> scope (that's why your "map" example worked better): > >> > >> julia> f(M) = [[i] for i=1:M] > >> > >> f (generic function with 1 method) > >> > >> > >> julia> f(10) > >> > >> 10-element Array{Array{Int64,1},1}: > >> > >> [1] > >> > >> [2] > >> > >> [3] > >> > >> [4] > >> > >> [5] > >> > >> [6] > >> > >> [7] > >> > >> [8] > >> > >> [9] > >> > >> [10] >
