Julia : repeat函数有意思

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wowotuo/article/details/82146136

https://docs.julialang.org/en/v1/base/arrays/#Array-functions-1

julia> repeat(1:2, inner=2)
4-element Array{Int64,1}:
 1
 1
 2
 2

julia> repeat(1:2, outer=2)
4-element Array{Int64,1}:
 1
 2
 1
 2
julia> repeat([1 2; 3 4], inner=(2, 1), outer=(1, 3))
4×6 Array{Int64,2}:
 1  2  1  2  1  2
 1  2  1  2  1  2
 3  4  3  4  3  4
 3  4  3  4  3  4


julia> repeat("ha", 3)
"hahaha"

julia> repeat('A', 3)
"AAA"

julia> repeat([1, 2, 3], 2)
6-element Array{Int64,1}:
 1
 2
 3
 1
 2
 3

julia> repeat([1, 2, 3], 2, 3)
6×3 Array{Int64,2}:
 1  1  1
 2  2  2
 3  3  3
 1  1  1
 2  2  2
 3  3  3

猜你喜欢

转载自blog.csdn.net/wowotuo/article/details/82146136