MathGroup Archive 2003

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

Search the Archive

Re: Simple Question -- Incrementing All Elemnts in A list by 1

  • To: mathgroup at smc.vnet.net
  • Subject: [mg44326] Re: [mg44290] Simple Question -- Incrementing All Elemnts in A list by 1
  • From: Murray Eisenberg <murray at math.umass.edu>
  • Date: Wed, 5 Nov 2003 10:01:04 -0500 (EST)
  • Organization: Mathematics & Statistics, Univ. of Mass./Amherst
  • References: <200311040824.DAA10546@smc.vnet.net>
  • Reply-to: murray at math.umass.edu
  • Sender: owner-wri-mathgroup at wolfram.com

    1 + {2, 3, 4, 45, 98}
{3, 4, 5, 46, 99}

This works because Plus has attribute Listable.  See Sections 1.2.3 and 
2.6.3 of The Mathematica Book, 5th Edition (or similar sections for 
earlier versions), whose electronic form is part of the Mathematica 
distribution.

While obviously one learns through experimentation, it's certainly worth 
your while to read at least the beginning of the book before proceeding 
very far with Mathematica.

Thiery Balser wrote:

> Hi,
> 
> I'm sort of stuck.
> 
> I would like to have all elements in a list incremted by a given number
> without defining a supplementary function.
> 
> What I've done so far is:
> 
> incFunc[n_]:=n+1;
> Map[incFunc,{2,3,4,45,98}]
> 
> which is all fine. It is only that I'm looking for a solution _without_
> defining the mentioned function incFunc.
> 
> 
> Thanks in advance,
> 
> Thiery
> 
> 
> 

-- 
Murray Eisenberg                     murray at math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305


  • Prev by Date: Where to reply to...
  • Next by Date: Re: Integrate...
  • Previous by thread: Re: Simple Question -- Incrementing All Elemnts in A list by 1
  • Next by thread: Re: Simple Question -- Incrementing All Elemnts in A list by 1