Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

Re: "Alternating" function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg63267] Re: [mg63260] "Alternating" function
  • From: ggroup at sarj.ca
  • Date: Thu, 22 Dec 2005 00:04:29 -0500 (EST)
  • References: <200512210435.XAA14743@smc.vnet.net>
  • Reply-to: ggroup at sarj.ca
  • Sender: owner-wri-mathgroup at wolfram.com

On Tuesday, December 20, 2005 at 23:35 GMT -0500, Renan wrote:

> I've tried using Nest but I don't find how to keep switching between
> Plus and Minus: I would need something that would return an "index" so
> I could keep track of when I need to "switch" the operation. (e.g. if
> the "index" is odd, the operation is "Plus", otherwise is "Minus")

You could define a dummy index variable at the beginning of your cell
(eg. i=1;). Then in your function, simply add the factor ((-1)^i++).
That way i is incremented every time the function is applied.


  • Prev by Date: Returning an empty sequence
  • Next by Date: Re: NDSolve
  • Previous by thread: Re: "Alternating" function
  • Next by thread: Re: "Alternating" function