MathGroup Archive 1996

[Date Index] [Thread Index] [Author Index]

Search the Archive

Not[OddQ] is not the same as EvenQ (sometimes)

  • To: mathgroup at
  • Subject: [mg3885] Not[OddQ] is not the same as EvenQ (sometimes)
  • From: "Arnold Seiken" <SEIKENA at>
  • Date: Sat, 4 May 1996 23:21:45 -0400
  • Sender: owner-wri-mathgroup at

Dear Mathematica experts,

Position[{2,3,4,5,6,7}, x_?(EvenQ[#]&)]
{{1}, {3}, {5}}
Position[{2,3,4,5,6,7}, x_?(!OddQ[#]&)]
{{0}, {1}, {3}, {5}}
Therefore, for this example, the pattern x_?(EvenQ[#]&) is not equivalent to
the pattern x_?(!OddQ[#]&). The latter matches with the head List of {2,3,4,5,6,7}, the former does not. But
Position[{-2,3,4,-5,6,7}, x_?(NonNegative[#]&)]
{{2}, {3}, {5}, {6}}
Position[{-2,3,4,-5,6,7}, x_?(!Negative[#]&)]
{{2}, {3}, {5}, {6}}
shows that the Head List is sometimes ignored by Position. Finally
Position[{1,3,5}, x_?(!OddQ[#]&)]
Position[{2,3,4,5,6,7}, x_?(!NumberQ[#]&)]
{{0}, {}}
Position[{2,3,4,5,6,7}, x_?(!Positive[#]&)]
seems to show that there are really three possible outcomes  when using Not in a pattern involving the Position command. This does not occur for either the Count or Cases command where you get what you expect to get. 

Count[{1,3,5,7}, x_?(EvenQ[#]&)]
Count[{1,3,5,7}, x_?(!OddQ[#]&)]
Any explanations?

Arnold Seiken


  • Prev by Date: Re: Windows 95 Problems
  • Next by Date: [Mg3897] Re: Wanted: a trick
  • Previous by thread: Re: Windows 95 Problems
  • Next by thread: Re: Not[OddQ] is not the same as EvenQ (sometimes)