Thanks for Rearrangement & Format
- To: mathgroup at smc.vnet.net
- Subject: [mg5438] Thanks for Rearrangement & Format
- From: Susan Rempe <rempe at euclid.chem.washington.edu>
- Date: Sat, 7 Dec 1996 00:26:13 -0500
- Sender: owner-wri-mathgroup at wolfram.com
Thanks to all who responded to my 2 questions.
The answers I liked best are the following:
1). To replace a term in a function without
letting rearrangement occur, clear the
attributes of the operator(s) and make
orderless. Explicitly order terms with Sort.
In[195]:= t=a+b+c+d;
In[196]:= ClearAttributes[Plus,Orderless]
In[197]:= t[[3]]=x
In[198]:= t
Out[198]= a + b + x + d
In[199]:= Sort[%]
Out[199]= a + b + d + x
2). To write a string and an expression to file,
In[210]:= gm=Cos[theta];
In[211]:= OpenWrite["foo.m",FormatType->FortranForm];
In[212]:= WriteString["foo.m", "gm(",12,",",12,")="];
In[213]:= Write["foo.m",gm];
In[214]:= !!foo.m
gm(12,12)=Cos(theta)
Thanks again to everyone for helping me out.
Susan Rempe