MathGroup Archive 2005

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

Search the Archive

Re: String[bring] vs "bring"

  • To: mathgroup at smc.vnet.net
  • Subject: [mg59351] Re: [mg59350] String[bring] vs "bring"
  • From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Date: Sun, 7 Aug 2005 03:46:48 -0400 (EDT)
  • References: <200508060530.BAA01232@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

The point is that String[bring] is not an string, just an object with  
head String. The key difference between it and a real string "bring"  
is that latter is an atom:


AtomQ["bring"]

True

but

AtomQ[String[bring]]


False

Also, your use of Cases in


Cases[ToString[bring], _String]

{}


fails because Cases looks only at parts of an expression, thus you  
need to use (for exmple)


Cases[{ToString[bring]}, _String]

{bring}

This, of course, will also work:


Cases[{String[bring]}, _String]

{String[bring]}

but that's just saying that String[bring] has head String. You could  
do the same with Integer:


Cases[{Integer[dog]}, _Integer]


{Integer[dog]}

But it still does not mean that Integer[dog] is a Mathematica integer.


Andrzej Kozlowski







On 6 Aug 2005, at 07:30, Kristen W Carlson wrote:

> Hi,
>
> Question: What is the difference between "bring" and String[bring] ?
> What is the utility of making them different?
>
> Question: What is the difference between "bring" and String[bring] ?
> What is the utility of making them different?
>
> "bring" ===String[bring]
>
> False
>
> Cases[{"bring"}, _String]
>
> {bring}
>
> Cases[String[bring], _String]
>
> {}
>
> Cases[ToString[bring], _String]
>
> {}
>
> InputForm[String[bring]]
>
> String[bring]
>
> InputForm["bring"]
>
> "bring"
>
> FullForm[String[bring]]
>
> String[bring]
>
> And yet:
>
> Head["bring"]
>
> String
>
> FullForm["bring"]
>
> "bring"
>
> ToString[bring]
>
> bring
>
> InputForm[%]
>
> "bring"
>
> Wha????
>
> Thanks,
>
> Kris
>
>


  • Prev by Date: Re: Specifying path to a non standard package
  • Next by Date: Redefining a function with a rule for coefficients
  • Previous by thread: Re: String[bring] vs "bring"
  • Next by thread: Re: String[bring] vs "bring"