Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum > General > > "Function Fun"

Post Reply:
Name:
Email Address:

Please send email when my message is replied to.

Url (optional):
Subject:
Message: view original message?
Attachment (optional):
Please answer this:7+1 =



Original Message (ID '125489') By Nasser M. Abbasi:
funcTest[list_List, str_String, count_Integer] := list[[count]] = str list1={a,b} funcTest[list1,"Help",1] Results in: {a, b} Set::setps: {a,b} in the part assignment is not a symbol. >> Yet, list1[[1]]="Help!!" {Help!!,b} Works. What is the problem? ----------------------------------- Mathematica passes things by value. You can't update a function parameter. To update an input, you must first make a copy of it, then update the copy, and return the copy. ------------------- funcTest[list_List,str_String,count_Integer]:=Module[{c=list}, c[[count]]=str; c ] list1={a,b}; list1=funcTest[list1,"Help",1] ---------------------- {"Help", b}