MathGroup Archive 2003

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

Search the Archive

Re: symbols to separate characters in a variable

  • To: mathgroup at smc.vnet.net
  • Subject: [mg42075] Re: symbols to separate characters in a variable
  • From: "Will Self" <wself at msubillings.edu>
  • Date: Wed, 18 Jun 2003 02:10:50 -0400 (EDT)
  • References: <bcmq5f$ss5$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

"cyberdude" <quake_earthNOSPAM at hotmail.com> wrote in message
news:bcmq5f$ss5$1 at smc.vnet.net...
> Hi,
>
> In mathematica, I try to separate characters in a variable by '_' but
> that seems to be problematic.  For example,
>
>
> In[1]:= ab_cd=1
>
> Set::patset: Warning: ab_cd in assignment ab_cd = 1
>      represents a named pattern; use symbol::tag to represent a message
name.
>
>
> In[2]:= ab_cd
>
>
>
> ab_cd in In[2] doesn't return 1.  It looks like a problem.  Can it be
> overcome?
>
> Are there other symbols that can separate characters in a variable to let
> the characters look 'not packed closely together'?  Thank you in advance.
>
>
> David

The underscore is reserved for patterns, and you can't use it in
symbols.

The tradition in Mathematica is to use long, descriptive names for
your objects, using words run together, and capitalize all but the
first word.  For example

numberOfPeanuts    totalWeightOfPeanuts

You may find this irksome but it really does have advantages.  Do
not capitalize the first character of your own symbols; in this way
you avoid clashing with the name of a built-in symbol.  This also
tells someone reading your work that these are your own symbols,
not built-in symbols.  For example, you might have a symbol called
numberMultiplier.  No problem that Mathematica already has one
called NumberMultiplier.  There is no conflict, and the reader
knows that it is your own symbol.

When you are doing fast and furious temporary work, you can create
two names:

numberOfPeanuts = 800

n := numberOfPeanuts

Then you can just type n instead of numberOfPeanuts.  Also, because
of the delayed assignment (colon-equal) if you change the value of
numberOfPeanuts, then n will change too.  When you are ready to
create a presentable document, you can replace all occurrences of n
with numberOfPeanuts.  (Careful use of Find and Replace works.)



  • Prev by Date: Re: Extracting Re and Im parts of a symbolic expression
  • Next by Date: Re: ack! simple partitioning problem making my head swim....
  • Previous by thread: RE: symbols to separate characters in a variable
  • Next by thread: Re: RE: symbols to separate characters in a variable