Julia 朱莉娅:向量的向量(数组的数组)

Julia 朱莉娅:向量的向量(数组的数组),julia,Julia,我试图在Julia中制作一个3D点的向量,我现在把它本身作为向量。但是,我不知道如何将这些向量转换成向量。我复制错误的最小示例是: foo = rand(3) #Vector Float64, 3 bar = Vector{Float64}[] #Vector Array{Float64,1} 0 append!(bar,foo) #Throws an error 在最后一行抛出错误 `convert` has no method matching convert(::Type{Array{F

我试图在Julia中制作一个3D点的向量,我现在把它本身作为向量。但是,我不知道如何将这些向量转换成向量。我复制错误的最小示例是:

foo = rand(3) #Vector Float64, 3
bar = Vector{Float64}[] #Vector Array{Float64,1} 0
append!(bar,foo) #Throws an error
在最后一行抛出错误

`convert` has no method matching convert(::Type{Array{Float64,1}}, ::Float64)
in copy! at abstractarray.jl:197
in append! at array.jl:478
in include_string at loading.jl:97
in include_string at C:\Users\Alex\.julia\v0.3\Jewel\src\eval.jl:36
in anonymous at C:\Users\Alex\.julia\v0.3\Jewel\src\LightTable\eval.jl:68
in handlecmd at C:\Users\Alex\.julia\v0.3\Jewel\src\LightTable/LightTable.jl:65
in handlenext at C:\Users\Alex\.julia\v0.3\Jewel\src\LightTable/LightTable.jl:81
in server at C:\Users\Alex\.julia\v0.3\Jewel\src\LightTable/LightTable.jl:22
in server at C:\Users\Alex\.julia\v0.3\Jewel\src\Jewel.jl:18
in include at boot.jl:245
in include_from_node1 at loading.jl:128
in process_options at client.jl:285
in _start at client.jl:354
有没有办法做到这一点,或者我是否遗漏了阻止这种结构的东西?我应该改用矩阵吗?到目前为止,我还没有对这些点进行迭代,而不是批量转换。

将第二个参数作为一个集合,因此
foo
的每个元素(每个元素都是
Int
)将无法添加。你可以做:

append!(bar,[foo for i in 1:1])

我想你在找我

push!(bar, foo)