I am trying to define a substitution that gives 1 for odd numbers and 0 for even numbers. My guess was (in a particular example)
{0, 1, 2, 3, 4, 5, 6} /. N_Integer -> If[EvenQ[N], 0, 1]
But the output is {1,1,1,1,1,1,1}
. The problem is in EvenQ[]
which is acting on a symbol, but I specified before that it should be applied only to integers, so I do not understand why it does not work.
Where is the problem? Does it have something to do with ->
?
:>
instead of->
. But then, why not useMod[list, 2]
? $\endgroup$