MathGroup Archive 2007

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

Search the Archive

NestListEffects function not working in 6.0

  • To: mathgroup at
  • Subject: [mg77042] NestListEffects function not working in 6.0
  • From: Jon Davis <jdavis at>
  • Date: Fri, 1 Jun 2007 02:46:24 -0400 (EDT)

I'm coming back to Mathematica after a couple of years and I just
upgraded to 6.0. I have relied on a function for quite awhile that I
got from a book by Richard Gaylord and Louis D'Andria titled
"Simulating Society".  The function is very useful for agent-based
simulations and for some reason, it doesn't seem to work in version
6.0... No incompatibilities are identified by the version advisory
scanner, so I'm not sure what to do. Can anyone help? Functions follow.
Any help is deeply appreciated!!! I can provide a notebook with example
usage on request.

NestListEffects::usage = "NestListEffects[f, expr, n, ReturnValues =E2=86=
{g, k}] returns a list of every kth element of NestList[f, expr, n]
after the application of g. NestListEffects[f, expr, n, SideEffects =E2=86=
{{g1, k1}, {g2, k2},...}] applies gi after every ki steps, but does not
effect return values.";

ReturnValues::usage = "ReturnValues is an option to NestListEffects
that determines what is returned and how often.";

SideEffects::usage = "SideEffects is an option to NestListEffects that
applies functions without effecting return values. The option
SideEffects does not affect return values";

Options[NestListEffects]={ReturnValues-> {#&, 1}, SideEffects-> {}};

NestListEffects[f_, expr_, n_, opts___]:= If[({ReturnValues,
SideEffects} /. {opts} /. Options[NestListEffects]) === {{#&, 1}, {=
NestList[f, expr, n],
   (* else *)
   Module[{c = 0, lis = {}, side, ret}, {ret, side} = {ReturnValues=
SideEffects} /. {opts} /. Options[NestListEffects];
    If[side === {}, side = {{Null, Infinity}}];
    Nest[( If[Mod[c, ret[[-1]]] === 0, lis = Join[lis, {First[ret=
][#, c]}]];
         Table[If[Mod[c, side[[i, -1]]] === 0, side[[i, 1]][#, c]],=
         #)&[f[#]]&, expr, n];

  • Prev by Date: Re: Re: String to List
  • Next by Date: Re: Re: Famous Mathematica 5.0 not working with Mathematica
  • Previous by thread: Re: String to List
  • Next by thread: Re: NestListEffects function not working in 6.0