MathGroup Archive 2006

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

Search the Archive

RE: Suggestions for translating a Do[] loop ...


It would seem
(Drop[ a * b, -1] + Drop[ r, 1]) / (1 + Drop[ b, -1] * Drop[ r, 1])
Should work

Paul  

-----Original Message-----
From: David Annetts [mailto:davidannetts at aapt.net.au] 
To: mathgroup at smc.vnet.net
Subject: [mg69796] [mg69773] Suggestions for translating a Do[] loop ...

Hi,

Given that a, b & r are lists of the same length, can anyone suggest a
translation of the following Do[] loop to something functional?  It
looks like an ideal application for Fold, but for me, the loop going
backwards is really obscuring things.

The loop is 

	Do[
    		r[[j]] = a[[j]] * (b[[j]] + r[[j + 1]]) / (1 + b[[j]] *
r[[j
+ 1]]),
    		{j, Length@a - 1, 1, -1}
    		];

with r[[Length@a]] = 0.

Many thanks,

Dave.


  • Prev by Date: Table command strange output when 'i' over 16
  • Next by Date: Re: Suggestions for translating a Do[] loop ...
  • Previous by thread: Re: Suggestions for translating a Do[] loop ...
  • Next by thread: Re: Suggestions for translating a Do[] loop ...