Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'pass-by-reference/pass-by-pointer instead of pass-by-value(copy)' topicStudent Support Forum > General > Archives > "pass-by-reference/pass-by-pointer instead of pass-by-value(copy)"

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

Subject (listing for 'pass-by-reference/pass-by-pointer instead of pass-by-value(copy)')
Author Date Posted
pass-by-reference/pass-by-pointer instead of ... M. Azim 10/10/99 7:02pm
Re: pass-by-reference/pass-by-pointer instead o... Aaron Honecker 10/15/99 11:00pm
Next Comment >Help | Reply To Topic