|
[Date Index]
[Thread Index]
[Author Index]
RE: Simple Question -- Incrementing All Elemnts in A li st by 1
- To: mathgroup at smc.vnet.net
- Subject: [mg44333] RE: [mg44290] Simple Question -- Incrementing All Elemnts in A li st by 1
- From: David.Annetts at csiro.au
- Date: Wed, 5 Nov 2003 10:01:33 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Hi Thiery,
> 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.
Something like ...
lst = Table[Random[Integer, {0, 100}], {100000}];
Timing[in1 = (++lst[[#]])& /@ Range[Length@lst];]
Timing[in2 = (# + 1)& /@ lst;]
should suffice. in2 appears in general faster than in1.
Regards,
Dave.
Prev by Date:
Re: FourierTransform of Sinc Function
Next by Date:
Re: Simple Question -- Incrementing All Elemnts in A list by 1
Previous by thread:
Re: Mathematica 5 crashes
Next by thread:
exporting a list of functions for use in a C function
|