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.

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 (RefLink[Splice, paclet:ref/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 (RefLink[Splice, paclet:ref/Splice]).