Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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
3  
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 Narain Nov 9 '13 at 18:26

2 Answers 2

up vote 5 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:

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

Your Answer

 
discard

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.