MathGroup Archive 2010

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

Search the Archive

Re: beginner question about syntax

  • To: mathgroup at smc.vnet.net
  • Subject: [mg109085] Re: beginner question about syntax
  • From: "David Park" <djmpark at comcast.net>
  • Date: Mon, 12 Apr 2010 22:59:06 -0400 (EDT)

Map maps the function onto to parts of the expression at Level 1, or at the
levels you specify. But a is just a Symbol and has no Parts or Level 1.
Therefore nothing happens.

But the second expression does have parts at Level 1:

a + b + c // FullForm 
Plus[a, b, c] 

So Map does operate on the items at Level 1, i.e., a, b and c.

You could also write Map in shortcut form using "/@" to stand for Map, and
#^2& to stand for the squaring Function:

#^2 & /@ (a + b + c)
a^2 + b^2 + c^2


David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/  




From: AK [mailto:aaarbk at googlemail.com] 

Hi,

I'm a fairly seasoned user of another system who's just started using
Mathematica. Although at the moment I'm just playing around with
Mathematica (without any specific task at hand), trying to figure out
the Mathematica way of doing things from the documentation
(particularly the examples) there are some things I can't seem to wrap
my head around. For example, can anyone explain the outputs for the
inputs below:
In[1]:= Map[Function[x, x^2], a]
Out[1]:= a
In[2]:=Map[Function[x, x^2], a + b + c]
Out[2]:= a^2 + b^2 + c^2

If I enclose the second argument of Map[] inside a list, I get the
expected output, but I don't understand what the operations given in
the example above represent and why the outputs are what they are.
Would appreciate an explanation for what's going here... thank you in
advance.




  • Prev by Date: Re: beginner question about syntax
  • Next by Date: Re: Bug in PadLeft/PadRight
  • Previous by thread: Re: beginner question about syntax
  • Next by thread: Re: beginner question about syntax