How to concatenate differently sized vectors in Julia?

Ale*_*lec 3 arrays vector concatenation julia

How can I concatenate arrays of different size with a "filler" value where the arrays don't line up?

a = [1,2,3]
b = [1,2]
Run Code Online (Sandbox Code Playgroud)

And I would like:

[1 2 3
 1 2 missing]
Run Code Online (Sandbox Code Playgroud)

Or

[1 2 3
 1 2 nothing]
Run Code Online (Sandbox Code Playgroud)

mca*_*ott 6

一种方法rstack是使用“参差不齐的堆栈”。它总是沿着一个新维度放置数组,因此给定向量,它们形成矩阵的列。(原始问题可能需要此结果的转置。)

julia> using LazyStack

julia> rstack(a, b; fill=missing)
3×2 Matrix{Union{Missing, Int64}}:
 1  1
 2  2
 3   missing

julia> rstack(a, b, reverse(a), reverse(b); fill=NaN)
3×4 Matrix{Real}:
 1    1  3    2
 2    2  2    1
 3  NaN  1  NaN
Run Code Online (Sandbox Code Playgroud)