MathGroup Archive 2007

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

Search the Archive

Re: NestListEffects function not working in 6.0

  • To: mathgroup at smc.vnet.net
  • Subject: [mg77109] Re: [mg77042] NestListEffects function not working in 6.0
  • From: DrMajorBob <drmajorbob at bigfoot.com>
  • Date: Mon, 4 Jun 2007 03:44:31 -0400 (EDT)
  • References: <7485188.1180896207467.JavaMail.root@m35>
  • Reply-to: drmajorbob at bigfoot.com

An example would be nice. What kind of inputs and outputs demonstrate the  
problem?

Bobby

On Fri, 01 Jun 2007 01:46:24 -0500, Jon Davis <jdavis at bus.wisc.edu> wrote:

> 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=
> =92
> {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=
> =92
> {{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]],
>  {i,
> Length[side]}];
>          c++;
>          #)&[f[#]]&, expr, n];
>     lis]
>    ];
>
>



-- 

DrMajorBob at bigfoot.com


  • Prev by Date: Re: MakeExpression problem
  • Next by Date: Re: pure function to generate a list of integrals
  • Previous by thread: Re: NestListEffects function not working in 6.0
  • Next by thread: Re: Re: NestListEffects function not working in 6.0