Is it possible to interleave two arrays in julia?
For example if a=[1:10]
and b=[11:20]
I want to be able to return
20-element Array{Int64,1}:
1
11
2
12
3
13
4
14
.
.
.
Somewhat similar to what ruby can do Merge and interleave two arrays in Ruby
Figured it out!
reshape([a b]',20,1)
and for something more general:
reshape([a b].',size(a,1)+size(b,1),1)
we can use a hack to get vectors instead of 1D arrays:
reshape([a b].',size(a,1)+size(b,1),1)[:]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With