Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Re: beginner question about syntax

  • To: mathgroup at smc.vnet.net
  • Subject: [mg109111] Re: beginner question about syntax
  • From: Bill Rowe <readnews at sbcglobal.net>
  • Date: Mon, 12 Apr 2010 23:03:57 -0400 (EDT)

On 4/12/10 at 6:53 AM, aaarbk at googlemail.com (AK) wrote:


>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

By default, Map works at level 1. A symbol with nothing assigned
to it has no level 1. You could have gotten the output you were
expecting by telling Map to work at level 0 which refers to the
entire expression. That is:

In[11]:= Map[Function[x, x^2], a, {0}]

Out[11]= a^2

>In[2]:=Map[Function[x, x^2], a + b + c]
>Out[2]:= a^2 + b^2 + c^2

This works since the expression a + b + c has a level 1.

>If I enclose the second argument of Map[] inside a list,

By doing that you create a level 1.

>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...

For more detail see

tutorial/LevelsInExpressions



  • Prev by Date: Re: Converting the integral of a sum into a sum of integrals
  • Next by Date: Re: beginner question about syntax
  • Previous by thread: Re: beginner question about syntax
  • Next by thread: Re: beginner question about syntax