| Author |
Comment/Response |
Ruben
|
12/12/07 1:44pm
Hi,
A have a function definition, that calls itself to perform an iterative task. I would like to store in an array (or a list) the results of each iteration for use in further computations. At the end of each run the function evaluates if an ending condition is true, if so the function should return the array all results. In the implementation, I have tried to pass the name of an array as an attribute, and use AppendTo to add the results. However, my program is not storing any data in the list. I am sure there should be an easy way to pass-by-reference the name of the list and return it properly. Here is a scheme of my function definition:
FunctionDef[x0_, y0_,….,z0_ , arrayname0_ ]:= Module[ {x=x0, y=y0, … arrayn=arrayname0},
Expr1;
Expr2;
.
.
.
ExprN;
AppendTo[arrayn, {Result1, Result2,….Resultm}]
.
.
.
If[endcondition, Return[arrayn], FunctionDef[x, y, …, arrayn] ];
]
Thanks in advance for your help. (PLEASE HELP ME)
Ruben
URL: , |
|