Here I got
A = [1, 2, 3]
B = [1, 0, 0, 1, 0, 1]
I want to create a matrix
C = [1, 0, 0, 2, 0, 3]
You can see B
is like a mask, The number of ones in B
is equal to the number of elements in A
. What I want is arrange elements in A
to the place where B
is 1
.
Any method without loop?