I would like to take an integer n defining the number of bits in my communication code and a vector defining the alphabet I am assigning to bits 0:n-1,
n
0:n-1
To easily convert zeros to -1 (and leave the ones intact) you can simply do
-1
minusOnes = 2 * zeroOnes - 1;