Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'Modifying list passed as argument' topicStudent Support Forum > General > Archives > "Modifying list passed as argument"

< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic
Author Comment/Response
qj
09/21/09 3:17pm

In Response To 'Re: Modifying list passed as argument'
---------
That does not work for lists already containing values.
With the following, I would like to get {4,2,6}.


test[list_] := Block[{x = 2}, Evaluate[list[[2]]] = x];
lst = {4, 5, 6};
test[lst];
lst

Set::setraw: Cannot assign to raw object 5. >>
{4, 5, 6}

URL: ,

Subject (listing for 'Modifying list passed as argument')
Author Date Posted
Modifying list passed as argument qj 09/16/09 4:52pm
Re: Modifying list passed as argument Peter Pein 09/19/09 7:34pm
Re: Re: Modifying list passed as argument qj 09/21/09 3:17pm
Re: Modifying list passed as argument yehuda ben-s... 09/24/09 02:26am
< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic