Re: Assign a value to a variable
- To: mathgroup at smc.vnet.net
- Subject: [mg63014] Re: Assign a value to a variable
- From: dh <dh at metrohm.ch>
- Date: Sun, 11 Dec 2005 04:56:35 -0500 (EST)
- References: <dnedkh$tf$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi Ben, The operator Set has the Attribute "HoldFirst". It therefore does not evaluate the lefthand side of lhs = rhs. You can force an evaluation by: Evaluate[lhs]=rhs Daniel Ben Becker wrote: > Hi! > > I have a list of variables: > vars = {a, b, c, d, e, f, g, h, i} > > and a list of numbers: > numbers = Range[9] > > Now i'd like to choose randomly a variable and a number. and then i'd > like to assign the number to the variable. > I thought of somehting like that: > > vars[[Random[Integer, {1, Length[vars]}]]] = > numbers[[Random[Integer, {1, Length[numbers]}]]] > > but it doesn't work. > > i hope you have an idea! > > thank you for answering! > > MFG Ben >