Re> FORTRAN
- To: mathgroup at yoda.physics.unc.edu
- Subject: Re> FORTRAN
- From: ross at macadam.mpce.mq.edu.au
- Date: Mon, 22 Jun 1992 14:09:04 +1000
Here is an elegant way to do what John Pender wants: First recreate his example ... In[1]:= ata=Table[Exp[-5 x],{x,10}]//N; In[2]:= InputForm /@ ata Out[2]= {0.00673794699908547, 0.00004539992976248488, 3.05902320501826*10^-7, 2.061153622438559*10^-9, 1.388794386496403*10^-11, 9.35762296884019*10^-14, 6.305116760146998*10^-16, 4.248354255291597*10^-18, 2.8625185805494*10^-20, 1.928749847963922*10^-22} Note the use of InputForm[] to get the * and ^ explicitly shown. Next define a function: In[3]:= FortranString = StringReplace[ ToString[InputForm[#]] ,"^"->"**" ]& Out[3]= StringReplace[ToString[#1], ^ -> **] & In[4]:= FortranString /@ ata //ColumnForm Out[4]= 0.00673794699908547 0.00004539992976248488 3.05902320501826*10**-7 2.061153622438559*10**-9 1.388794386496403*10**-11 9.35762296884019*10**-14 6.305116760146998*10**-16 4.248354255291597*10**-18 2.8625185805494*10**-20 1.928749847963922*10**-22 These are now text strings which can be read into a file. (It took a lot of false starts using Format[] before I hit upon this method.) _______________________________ Ross Moore | Mathematics Dept | Macquarie University | North Ryde, Sydney | Australia | | ross at macadam.mpce.mq.edu.au | ______________________________|