Re: Q: Recursion on a list
- To: mathgroup at smc.vnet.net
- Subject: [mg28902] Re: Q: Recursion on a list
- From: Ignacio Rodriguez <ignacio at sgirmn.pluri.ucm.es>
- Date: Fri, 18 May 2001 01:13:05 -0400 (EDT)
- Organization: UCM
- References: <9e02kg$305@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
The easiest way seems the use of Do Do[r[t]=t,{t,0,1000}] x[0]=1 and then Do[x[t]=x[t-1](1+r[t]),{t,1,1000}]//Timing {0.08 Second, Null} msc wrote: > Greetings, > > I'm looking for an efficient method (i.e., with the use of an explicit loop) > for the following problem. I am working with large lists (several thousand > elements) of data. Denote one such list r. I would like to define a new list > x such that: > > x[0] = 1.0 > > x[t] = x[t-1]*(1.0 + r[t]) > > Can anyone suggest an efficient way? > > Thanks in advance, > > Mark -- Ignacio Rodriguez Ramirez de Arellano Unidad de RMN Universidad Complutense Paseo Juan XXIII, 1 Madrid 28040, Spain Tel. 34-91-394-3288 Fax 34-91-394-3245 e-mail: ignacio at sgirmn.pluri.ucm.es