Message Boards Message Boards

0
|
5731 Views
|
1 Reply
|
2 Total Likes
View groups...
Share
Share this post:

Assign values to a list

Posted 11 years ago
{x + y, x + w, 2*z, y + x} /. {w, x, y, z} -> {0.2, 0.1, 0.5, 0.8}

does not work.




What I really want is, to use random values to have a look at the value of the experssion, like this:
{x + y, x + w, 2*z, y + x} /. {w -> 0.2, x -> 0.1, y -> 0.5, z -> 0.8}

If I have many variables, is there a better way to assign the values? I want to give {w,x,y,z} 
{w,x,y,z} -> Table[RandomReal[], {i, 1, 4}]

Many thanks!
POSTED BY: Casper YC
In[1]:= Thread[{w, x, y, z} -> Table[RandomReal[], {i, 4}]]

Out[1]= {w -> 0.663387, x -> 0.445217, y -> 0.928062, z -> 0.738172}
POSTED BY: Ilian Gachevski
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract