MathGroup Archive 2005

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

Search the Archive

Re: String[bring] vs "bring"

  • To: mathgroup at smc.vnet.net
  • Subject: [mg59375] Re: String[bring] vs "bring"
  • From: "dkr" <dkrjeg at adelphia.net>
  • Date: Sun, 7 Aug 2005 03:47:06 -0400 (EDT)
  • References: <dd1itn$1et$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

There are two types of expressions in Mathematica--normal expressions
and atoms. Normal expressions are expressions that can be written in
the form:

head[p1,p2,...] where head, p1, p2 and so forth are each expressions
themselves.

Atoms are expressions that cannot be broken down into smaller
expressions.  In Mathematica, strings are treated as atoms.  Your
difficulties arise because you are trying to treat a string as a normal
expression.

Other comments:

"bring"===ToString[bring]   yields True

Cases[String[bring], _String]   yields False because Cases by default
searches for a match over the first level of the expression.  By adding
an explicit level spec to Cases we find:

In[2]:=
Cases[String[bring],_String,{0}]
Out[2]=
{String[bring]}

Alternatively, enclosing String[bring] in a list first and using the
default level spec yields:

In[3]:=
Cases[{String[bring]},_String]
Out[3]=
{String[bring]}

Again, because of the level spec, Cases[ToString[bring], _String]
(which is equivalent to Cases["bring" _String])  yields {}, but

In[5]:=
Cases[{ToString[bring]}, _String] 

Out[5]=
{bring}


  • Prev by Date: Re: Hankel matrix?
  • Next by Date: Re: String[bring] vs "bring"
  • Previous by thread: Re: String[bring] vs "bring"
  • Next by thread: Re: String[bring] vs "bring"