Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

Re: ! operator

  • To: mathgroup at smc.vnet.net
  • Subject: [mg55949] Re: [mg55927] ! operator
  • From: "Wolf, Hartmut" <Hartmut.Wolf at t-systems.com>
  • Date: Tue, 12 Apr 2005 05:25:59 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

>-----Original Message-----
>From: DongGook Park [mailto:dgpark6 at sunchon.ac.kr] 
To: mathgroup at smc.vnet.net
>Sent: Sunday, April 10, 2005 12:55 PM
>Subject: [mg55949] [mg55927] ! operator
>
>
>Hi,
>
>Could you explain a mysterious behaviour of "! operator" as 
>shown below?
>
>
>In[43]:=
>MemberQ[{1,2,3},3]
>
>Out[43]=
>True
>
>In[47]:=
>!MemberQ[{1,2,3},3]
>(*  Here Mathematica does not give any response!  *)
>
>In[48]:=
>Not@MemberQ[{1,2,3},3]
>
>Out[48]=
>False
>
>
>Considering the description from Mathematica help:
>	"!expr is the logical NOT function. It gives False if 
>expr is True,
>and True if it is False."
>This behaviour seems quite suspicious?
>
>DongGook
>
[...]


If you continue reading Help, you might get a suspicion, that "!"  at
the beginning of a line is a bit "overloaded" syntactically. Move away
from that, and parsing will be directed to the right way:

In[26]:= Identity[! MemberQ[{1, 2, 3}, 3]]
Out[26]= False

In[11]:= (! MemberQ[{1, 2, 3}, 3])
Out[11]= False

Whereas 

In[24]:= ! (MemberQ[{1, 2, 3}, 3])

In[18]:= ! ! ! MemberQ[{1, 2, 3}, 3]

Will not do.

Clearly

In[16]:= Hold[! ! ! MemberQ[{1, 2, 3}, 3]] // FullForm
Out[16]//FullForm=
Hold[Not[Not[Not[MemberQ[List[1, 2, 3], 3]]]]]

is parsed right.


Looking at MakeExpression reveals the problem

In[22]:= MakeExpression["!MemberQ[{1,2,3},3]"]
Out[22]= ErrorBox[ErrorBox["!MemberQ[{1,2,3},3]"]]

In[23]:= MakeExpression["(!MemberQ[{1,2,3},3])"]
Out[23]= HoldComplete[! MemberQ[{1, 2, 3}, 3]]


Don't be vexed! This is not a deep-seated bug, but a vestige of mixed
syntax.

--
Hartmut Wolf


  • Prev by Date: Re: ! operator
  • Next by Date: Re: OSX version of Extrapackages folder
  • Previous by thread: Re: Re: Re: Re: ! operator
  • Next by thread: cannot evaluate in HelpBrowser (Win XP)