Splicing Wolfram Language Output into External Files

If you want to make use of Wolfram Language output in an external file such as a program or document, you will often find it useful to "splice" the output automatically into the file.

Splice["file.mx"]splice Wolfram System output into an external file named , putting the results in the file file.x
Splice["infile","outfile"]splice Wolfram System output into infile, sending the output to outfile

Splicing Wolfram Language output into files.

The basic idea is to set up the definitions you need in a particular Wolfram System session, then run Splice to use the definitions you have made to produce the appropriate output to insert into the external files.

#include "mdefs.h"

double f(x)
double x;
{
double y;

y = <* Integrate[Sin[x]^5, x] *> ;

return(2*y - 1) ;
}

A simple C program containing a Wolfram Language formula.

#include "mdefs.h"

double f(x)
double x;
{
double y;

y = -5*Cos(x)/8 + 5*Cos(3*x)/48 - Cos(5*x)/80 ;

return(2*y - 1) ;
}

The C program after processing with Splice.