Re: Using Mathematica to create body of switch() statement
- From: Jon McLoone <jonm@xxxxxxxxxxxxx>
- Date: Mon, 9 Jun 2008 10:03:33 -0700 (PDT)
On Jun 6, 3:49 pm, Robert Buchanan <j.robert.bucha...@xxxxxxxxxxx>
wrote:
Hello,
I am writing some MathLink routines, which make use of some switch
statements in C which have a lot of cases. I have written a function
in Mathematica which automatically generates the lines in the body of
the switch statement. I thought I would use Splice[] to have
Mathematica insert those lines into the appropriate C source file. My
first naive attempt had my Mathematica function loop through a bunch
of Print[] statements, but Splice[] places Null in the C file since
the output of Print[] is Null. I could create a long string of the
case statements for the switch body, but then Splice[] would include
them in the C file as a literal string.
If you have managed to use Splice[] or some other technique to insert
Mathematica-generated C language statements into a C source code
file, please outline the procedure for doing so.
Thanks,
Bob Buchanan
If you can create strings, I would do that and then use
Splice[sourcefile, FormatType -> OutputForm]
...to prevent the string marks being inserted into the target file.
.
- References:
- Using Mathematica to create body of switch() statement
- From: Robert Buchanan
- Using Mathematica to create body of switch() statement
- Prev by Date: Combing braids
- Next by Date: Simple question about PlotLegend problem in Mathematica 6
- Previous by thread: Re: Using Mathematica to create body of switch() statement
- Next by thread: Re: Using Mathematica to create body of switch() statement
- Index(es):
Relevant Pages
|