Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'Passing an array by reference - recurrence' topicStudent Support Forum > General > "Passing an array by reference - recurrence"

Next Comment >Help | Reply To Topic
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: ,

Subject (listing for 'Passing an array by reference - recurrence')
Author Date Posted
Passing an array by reference - recurrence Ruben 12/12/07 1:44pm
Re: Passing an array by reference - recurrence yehuda ben-s... 12/13/07 07:32am
Re: Re: Passing an array by reference - recurre... Ruben 12/14/07 7:46pm
Next Comment >Help | Reply To Topic