Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: How to find one expression in terms of another expression?
Replies: 7   Last Post: Jun 25, 2011 4:33 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
J.Frazer

Posts: 13
Registered: 3/9/11
Multiple use of Set on lists
Posted: Jun 20, 2011 6:51 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hello,

I have a largish list of awkwardly "indexed variables", of the form cs =
{c[1/2][-(1/2)][1/2][-(1/2)][-1], c[1/2][-(1/2)][1/2][1/2][-1]......etc....
....} which need to be assigned random values multiple times inside a Do loop. I was hoping I could generate a new list of random numbers each time then do something like

MapThread[Set, {cs, rands}]

Where "rands" would be the list of random numbers. I'm clearly misunderstanding how MapThread works though as this doesn't work. Rather than getting "c[1/2][-(1/2)][1/2][-(1/2)][-1]=new random number", instead "old random number=new random number" is what seems to be happening.

As a last resort I thought I would just clear the variables at the beginning of the do loop but you can't use Clear to do this and I don't see how you can apply "=." (Unset) over a list either.

Any suggestions?

Many thanks,

Jonny






Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.