I have a list with negative and positive numbers
list = {-1, -2, 1, 2}
and I want to replace all negative values with 0 and all positive values with 1 simultaneously. I only managed to replace one value at a time and don't know how to add a second condition. I did the following
list /. x_ /; x<0->1
I want something like:
list /. x_ /; {x<0->0 && x>0->1}
but this does not work. So how to add a second condition?
Boole[Thread[list > 0]]will work nicely. – J. M.'s missing motivation Jul 05 '15 at 02:40