MathGroup Archive 2001

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

Search the Archive

Trouble with Splice for Java (i.e. there is no JForm)


Hello all,

I can't figure out how to output Java language constructs using Splice, like
I can for Fortran and C/C++ files.

For example, here is how x^2 is represented in different languages:

C/C++ :   Power(x,2)
Fortran:   x**2
TeX     :   x^2
Java     :  Math.pow(x,2)

Since there is no JForm command in Mathematica, I have been trying to use
CForm.   However, I can't figure out how to output the Java syntax.  If I
try something like this:

x^2/.Power->Math.pow

then the CForm comes out like this:

Dot(Math,pow)(x,2)

If I try something like this:

x^2/.Power->"Math.pow"

then the CForm comes out like this:

"Math.pow"(x,2)

Can someone help me understand how to get x^2 to output as Math.pow(x,2)
please?  Thank you.

Regards, Matt

--
Matthew D. Langston
SLD, Stanford Linear Accelerator Center
langston at SLAC.Stanford.EDU




  • Prev by Date: photonic band gaps
  • Next by Date: Re: Matrix of possible combinations of N elements
  • Previous by thread: photonic band gaps
  • Next by thread: Re: Trouble with Splice for Java (i.e. there is no JForm)