Why the following code works
using Combinatorics
all_sequences = []
for i in 2:4
for j in permutations(1:4, i)
push!(all_sequences, collect(j))
end
end
and this one does not
using Combinatorics
all_sequences = Array{Array{Int64,1},1}[]
for i in 2:4
for j in permutations(1:4, i)
push!(all_sequences, collect(j))
end
end
and gives the error message: ERROR: MethodError: Cannot `convert` an object of type Int64 to an object of type Array{Int64,1}
.
When I specify the array all_sequences
type as Array{Array{Int64,1},1}
, I got the error. However, the array all_sequences
type is nothing but Array{Array{Int64,1},1}
, no?