MathGroup Archive 2012

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

Search the Archive

Re: How to Multiply a Sequence of #s that depends on the previous #

  • To: mathgroup at smc.vnet.net
  • Subject: [mg125092] Re: How to Multiply a Sequence of #s that depends on the previous #
  • From: "Nasser M. Abbasi" <nma at 12000.org>
  • Date: Tue, 21 Feb 2012 06:12:43 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com

On 2/20/2012 1:47 AM, Clutch wrote:
> I have a list of #s : 1.10, 1.15, 1.20, 1.35.
>
> I start off with 50 and the first # is 50 * 1.10.
> The second # is the first # * 1.15.
> The third # is the second # * 1.20.
> The fourth # is the third # * 1.35.
>
> I want to maintain a list of these #s.
> How can this be done efficiently in Mathematica without running for loops?
>

one way:

lst = {1,2,3,4};
lst[[#]]*lst[[# + 1]] & /@ Range[Length[lst] - 1]

---> {2, 6, 12}

--Nasser



  • Prev by Date: How I can I optimize the following code in order to get very short running time
  • Next by Date: Why the FourierTransform gives two different answers?
  • Previous by thread: Re: How to Multiply a Sequence of #s that depends on the previous #
  • Next by thread: Re: How to Multiply a Sequence of #s that depends on the previous #