| Author |
Comment/Response |
M. Azim
|
10/10/99 7:02pm
Mathematica Ver.3.0
Is it possible to pass values by pass-by-reference or by pass-by-pointer
rather than by pass-by-value, in functions?
For example: Consider the following pseudocode:
(*******program to increment each element of list********)
L1={0,1,2,3,4,5,6,7};
IncrementList=
Function[{ListOne},Do[j=Take[ListOne,{i}];j++,{i,Length[ListOne]}]
];
Print[ListOne];
(***************************************************)
(****The desired output is: {1,2,3,4,5,6,7,8}*******)
(***************************************************)
If this function is called by the statement:
IncrementList[L1];
then the original list is outputed. However, had the list been passed by
reference (or as a pointer) as in the following C/C++ pseudocode, then
the original list would've been changed.
//prototype for function IncrementList
List IncrementList(List& ListOne);
So: Is it possible to pass-by-reference or pass-by-pointer in
Mathematica??? (It should be since it was written in C?C++?
Correct???)
Thanx in advance for replies.
URL: , |
|