Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The !True returns False but how can I negate a boolean vector such as {True, False, True}? The exclamanation mark does not work here like this !{True,False,True}.

share|improve this question
doing ??Not shows Not is not Listable. If a function foo is Listable, then one can write foo[{....}], and then foo will automatically by applied to each element in the list. For example, if you do ??Sin you'll see it says it is Listable. For non-listable functions, you can use Map, as in Map[Not,{True,False,True}] or Not[#] & /@ v etc... So, the first thing to always check is to do ?? in order to see if a function is Listable or not. – Nasser Nov 9 '13 at 17:15
@Nasser: Not[#] & can be written more concisely as Not. – Rahul Nov 9 '13 at 18:26
up vote 6 down vote accepted

One straightforward way to negate vectors is to use the full form of !, which it Not

q = {True, True, False};
Not /@ q
{False, False, True}

or equivalently Map[Not, q].

share|improve this answer


Thread[!{True, False, True}]
(* {False, True, False} *)
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.