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: [mg44339] Re: Simple Question -- Incrementing All Elemnts in A list by 1
  • From: "Eckhard Hennig" <aidev at n-o-s-p-a-m.kaninkolo.de>
  • Date: Wed, 5 Nov 2003 10:01:55 -0500 (EST)
  • References: <bo7pfk$am8$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

----- Original Message ----- 
From: "Thiery Balser" <thiery.balser at gmx.net>
To: mathgroup at smc.vnet.net
Subject: [mg44339] Simple Question -- Incrementing All Elemnts in A list by 1

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

You can do this with a pure function (look up "Function" in the help
browser):

In[1]:= # + 1 & /@ {2, 3, 4, 45, 98}

Out[1]= {3, 4, 5, 46, 99}

Best regards,

  Eckhard

--
Dr.-Ing. Eckhard Hennig
www.kaninkolo.de/ai
aidev \at kaninkolo \dot de



  • Prev by Date: Re: Simple Question -- Incrementing All Elemnts in A list by 1
  • Next by Date: Re: Simple Question -- Incrementing All Elemnts in A list by 1
  • 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