| Author |
Comment/Response |
yehuda ben-shimol
|
09/24/09 02:26am
Hi,
What you need here is a "call by reference" mechanism that overpasses the ordinary evaluation process of Mathematica, which is a call by value
you can do it in two ways, the first one is preferred
SetAttributes[test, HoldAll]
test[list_] := Block[{x = 2}, list[[2]] = x];
lst = {4, 5, 6};
test[lst];
lst
OR
test1[list_] := Block[{x = 2}, list[[2]] = x];
lst = {4, 5, 6};
test1[Unevaluated[lst]];
lst
in both cases the list lst is not evaluated and passed as is to the function
yehuda
URL: , |
|