| Author |
Comment/Response |
Jeffrey
|
01/31/01 12:50pm
Working with Mathematica 4.0.1.0 for Students, I have been having problems assigning values to list elements within a user-defined function. For example:
listone = {1, 1, 1, 1}
f[x_List] := x[[1]] = 0
f[listone]
And the error message I get:
Set::''setps'': ''\!\({1, 1, 1, 1}\) in assignment of part is not a symbol.''
Performing the operation outside a function is obviously no problem:
listone[[1]] = 0
0
listone
{0, 1, 1, 1}
Similar attempts to reassign values are also unsuccessful within functions, such as:
h[x_List] := Do[x[[2]]++, {i, 1, 5}]
Is this just not allowed? Is there a better way to go about this?
URL: , |
|