BinaryWrite and Position in Mathematica 6
- To: mathgroup at smc.vnet.net
- Subject: [mg83244] BinaryWrite and Position in Mathematica 6
- From: "L. Dwynn Lafleur" <lafleur at louisiana.edu>
- Date: Fri, 16 Nov 2007 05:22:09 -0500 (EST)
- Organization: U of Louisiana at Lafayette
I do not understand the following results from Mathematica 6.0.1.0 running in Windows XP (SP2): In[1]:= a={{2}} Out[1]= {{2}} In[2]:= b=Position[{x,y,z},y] Out[2]= {{2}} In[3]:= a==b Out[3]= True >From the above results, we see that although they produced differently, a and b are apparently identical. Now I attempt to write each to a file using BinaryWrite: In[4]:= BinaryWrite["aFile.dat",a,"Integer32"] Out[4]= aFile.dat In[5]:= BinaryWrite["bFile.txt",b,"Integer32"] During evaluation of In[5]:= BinaryWrite::nocoerce: {2} cannot be coerced to the specified format. >> Out[5]= $Failed BinaryWrite writes a successfully, but fails on b. However, consider the following: In[6]:= BinaryWrite["bFile2.txt",ToExpression[b],"Integer32"] Out[6]= bFile2.txt Why do I need to convert b before writing it to a file? I thought that "a==b -> True" indicates a and b are identical and therefore should be treated in the same way by Mathematica. What am I overlooking? ==================================== L. Dwynn Lafleur Professor of Physics University of Louisiana at Lafayette ====================================