MathGroup Archive 2010

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

Search the Archive

Re: beginner question about syntax


AK,
Whenever Mathematica seems to be doing something nonsensical (based on
what you are seeing on the screen,) then FullForm[] is your friend.
What you see in your notebook are expressions formatted to be human-
readable.  FullForm[] lets you see the structure that Mathematica is
actually working with.

In[14]:=
FullForm[a]

Out[14]//FullForm= a

In[15]:=
FullForm[a + b + c]

Out[15]//FullForm= Plus[a, b, c]

Mathematica expressions are always in the form of head[elem1,
elem2, ...].  Of course, you may not see that structure explicitly
unless you use FullForm[].  The function Map[f, expr] applies f to
each element on the first level in expr.  Looking at the FullForm of
a, you see that a has no first level (it is all head), thus there is
nothing to Map f to.   Plus[a,b,c] has the head Plus and three
elements (a, b, and c) at the first level, so f gets mapped to them.

Hope this helps,
Daniel


  • Prev by Date: Re: List Manipulation: Conditionally changing y value when x value
  • Next by Date: Strange memory behavoir of Norm
  • Previous by thread: beginner question about syntax
  • Next by thread: Re: beginner question about syntax