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: [mg77064] Re: NestListEffects function not working in 6.0
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Sat, 2 Jun 2007 04:19:03 -0400 (EDT)
  • References: <f3ofsh$p6j$1@smc.vnet.net>

Hi,

a) you post code to a news group that is not written by you
    and I would expect, that this violate the copyright of the
    authors
b) your mail client has corrupted the code listing and

    =E2=86=
    =92

    the inserted = characters have destroyed the code.
c) when you re-post the code, it would be fine, when you can
    append an example of the usage, the result you expect and
    the result that came out ..

Regards
   Jens

Jon Davis 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]
>    ];
> 


  • Prev by Date: Re: Latex and \sum
  • Next by Date: Problem with Mathematica 6
  • Previous by thread: Re: NestListEffects function not working in 6.0
  • Next by thread: Re: NestListEffects function not working in 6.0