Re: Error message need explaination in english
- To: mathgroup at smc.vnet.net
- Subject: [mg78673] Re: Error message need explaination in english
- From: David Bailey <dave at Remove_Thisdbailey.co.uk>
- Date: Fri, 6 Jul 2007 03:34:12 -0400 (EDT)
- References: <f6if0b$428$1@smc.vnet.net>
JGBoone at gmail.com wrote: > So i put in these commands > > Q=Range[10]; > size[group_]=Length[group]; > metareplace[group_] := (group[[Random[Integer, {1, size[group]}]]] = > hubl[metacommunity]); > (*takes random element of community size and replaces it with random > element of metacommunity by way of the function hubl[group_]*) > metareplace[Q] > > > and get this error message > > Set::setps: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} in assignment of part is > not a symbol > > looking at the help menu only confuses me further. can anyone tell me > in layman's terms what the messages means? > thanks > > This is a common error. It happens because you are passing the value of Q to metareplace - not Q itself - so that you end up executing something like {1,2,3,4,5,6,7,8,9,10}[[7]]=something; One solution is to stop your function evaluating its argument by using SetAttributes[metareplace, HoldAll]; There is another apparent problem with your code however, because your definition of 'size' should use := - otherwise the RHS is evaluated to 0 once and for all. David Bailey http://www.dbaileyconsultancy.co.uk