I'd like to use Boolean expressions as numeric values, as in:
a = 3 < 2
b = 3
a * b
but the final result of that is 3 False, instead of 0. I can do something like:
a = 3 < 2
b = 3
a * b /. False -> 0 /. True -> 1
but that seems awkward. I suppose I can make a function to do these replacements, but is there a more natural or a builtin way to do this?
a = Boole[3 < 2]
is what you are looking for. $\endgroup$a * b /. {False -> 0 ,True -> 1}
. $\endgroup$