Re: Simple Question -- Incrementing All Elemnts in A list by 1
- To: mathgroup at smc.vnet.net
- Subject: [mg44384] Re: Simple Question -- Incrementing All Elemnts in A list by 1
- From: Mariusz Jankowski<mjankowski at usm.maine.edu>
- Date: Fri, 7 Nov 2003 05:16:34 -0500 (EST)
- Organization: University of Maine System testbed server
- References: <bo7pfk$am8$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Thiery, there are many ways. The simplest, with x as your list, use (read about listable operators)
x+1
else, for more complicated operations learn to use pure functions
Map[ Function[#+1], x]
But you can also accomplish the same with Table and Do.
Mariusz
>>> Thiery Balser<thiery.balser at gmx.net> 11/4/2003 3:54:12 AM >>>
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