If you don't need to short-circuit, you can multiply 0 or 1 times each alternative using boolean operators (or sign). (x>0)*1+(~x)0+(x<0)-1
Octave has the ifelse / merge command, which is exactly what you want. merge(x>0,1,merge(x<0,-1,0))