Re: C-formatted strings back to Expressions
- To: mathgroup at smc.vnet.net
- Subject: [mg69960] Re: C-formatted strings back to Expressions
- From: dimmechan at yahoo.com
- Date: Thu, 28 Sep 2006 06:16:01 -0400 (EDT)
- References: <efdkii$v7$1@smc.vnet.net>
Hello. It is very easily to convert one form to another. CForm[Expand[(x+Sqrt[y])^2]] Power(x,2) + 2*x*Sqrt(y) + y InputForm[%] x^2 + 2*x*Sqrt[y] + y StandardForm[%] \!\(x\^2 + 2\ x\ \@y + y\) CForm[Expand[(x+Sqrt[y])^2]] Power(x,2) + 2*x*Sqrt(y) + y FortranForm[%] x**2 + 2*x*Sqrt(y) + y StandardForm[%] \!\(x\^2 + 2\ x\ \@y + y\) TeXForm[Sqrt[x^2+y^2]] \sqrt{x^2+y^2} MathMLForm[%] <math> <msqrt> <mrow> <msup> <mi>x</mi> <mn>2</mn> </msup> <mo>+</mo> <msup> <mi>y</mi> <mn>2</mn> </msup> </mrow> </msqrt> </math> OutputForm[%] 2 2 Sqrt[x + y ] As another example consider str=FromCharacterCode[Table[Random[Integer,{90,120}],{20},{2}]] {x],rm,]q,_i,v`,to,jm,pq,mh,jx,Zi,a],]n,gm,r^,ci,`w,qf,kg,e[} CForm[str] List("x]","rm","]q","_i","v`","to","jm","pq","mh","jx","Zi","a]","]n","gm","r^","ci","`w","qf","kg","e[") InputForm[%] {"x]", "rm", "]q", "_i", "v`", "to", "jm", "pq", "mh", "jx", "Zi", "a]", "]n", "gm", "r^", "ci", "`w", "qf", "kg", "e["}