MathGroup Archive 2005

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

Search the Archive

Re: String[bring] vs "bring"

  • To: mathgroup at smc.vnet.net
  • Subject: [mg59363] Re: String[bring] vs "bring"
  • From: David Bailey <dave at Remove_Thisdbailey.co.uk>
  • Date: Sun, 7 Aug 2005 03:46:57 -0400 (EDT)
  • References: <dd1itn$1et$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

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
> 
Hi,

Perhaps your objection to this comes from experience with another 
language. I would not expect String["xxx"] to be the same as "xxx", just 
as I would not expect List[{a,b,c}] to be the same as {a,b,c}. You just 
have to accept that when you apply Head to a string, or a number, or a 
symbol, the thing that you get back has a slightly different meaning to 
the result you get if you apply Head to f[a,b,c].

Maybe it would have been better to have supplied two functions, one to 
identify atomic objects and another to get the head of a compound one - 
but they didn't, and it is too late now. Of course, it would be easy to 
write such a function.

David Bailey
http://www.dbaileyconsultancy.co.uk


  • Prev by Date: Re: coefficient of a polynomial term
  • Next by Date: Re: Specifying path to a non standard package
  • Previous by thread: Re: String[bring] vs "bring"
  • Next by thread: Re: String[bring] vs "bring"