0

I'd like to construct a function, that changes its own input. The code

SetAttributes[f, HoldFirst];   l={1,2,3};
f[l_List] := Module[{i}, For[i=1, i<=Length@l, i++, Print[i]; l[[i]]=1;]];
f[l];   l

returns {1,2,3} instead of {1,1,1}. What am I doing wrong?

This and this post did not help.

Leo
  • 1,155
  • 5
  • 14

0 Answers0