MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

BinaryWrite and Position in Mathematica 6

  • To: mathgroup at
  • Subject: [mg83244] BinaryWrite and Position in Mathematica 6
  • From: "L. Dwynn Lafleur" <lafleur at>
  • 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 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 

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 

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

  • Prev by Date: Re: Minimizing Mathematica file size for source code control?
  • Next by Date: Re: DelaunayTriangulation[] output
  • Previous by thread: Re: Piecewise inside a Module or Block, I don't understand this behavior.
  • Next by thread: Re: BinaryWrite and Position in Mathematica 6