Why would this function work with a copy of the function variable:
Clear[zero]
zero[list_] := Module[{listCopy = list}, listCopy[[2]] = 0; listCopy]
zero[{1, 2, 3, 4, 5}]
(* {1, 0, 3, 4, 5} *)
but not when using the variable directly?
Clear[zero]
zero[list_] := Module[{}, list[[2]] = 0; list]
zero[{1, 2, 3, 4, 5}]

listwill not work as the value forlistwill be directly plugged into the RHS of the equation. However, when usinglistCopy, wouldn't the value oflistCopybe plugged in as well? (elaboration:Clear[zero]; zero[list_] := Module[{listCopy = list}, Print[listCopy]; listCopy[[2]] = 0; listCopy]; zero[{1, 2, 3, 4, 5}]). DoesSetbelong to a class of function (likeAppendToin your answer) that only takes symbol, which may or may not be associated with a value? – seismatica Aug 05 '14 at 04:34Sethas theHoldFirstattribute which keepslistCopy[[2]]from evaluating, andSetrecognizes this as a special expression and perform the in-place modification. There is controlled evaluation of the first argument ofSetwhich allows patterns to expand etc., but it doesn't relate to your use here. If you wish to know more about that let me know and I'll find relevant material. – Mr.Wizard Aug 05 '14 at 04:57