I’m trying to make an example Pluto notebook, showing how some Julia functions can be manipulated by Symbolics and Converted to C. This all looks nice. But I don’t know the syntax once the function has generated C code to display it in markdown as C-code.
For Example:
@variables start stop num u
qi=structure1(start,stop,num)
f=function1(qi,u)
fc=build_function(f,start,stop,num;target=Symbolics.CTarget(),fname="function1")
Gives me a nice C function, but I want to do something like this in the notebook.
md"""
Then we can symplify and convert the code to C, or MATLAB or Julia.
```C
$(fc)
`` ` # ignore space
"""
Which I ultimately would love to look like this in the display with the newlines expanded, etc:
#include <math.h>
void function1(double* du, const double RHS1, const double RHS2, const double RHS3) {
du[0] = ifelse(u <= RHS1, 1, ifelse(u >= RHS2, RHS3, 1 + ((-1 + RHS3) * (u + -1 * RHS1 * 1)) / (RHS2 + -1 * RHS1 * 1)));
}
I don’t know if it helps too much, but is there a C pretty print option for markdowns somewhere hiding? I can’t be the first person to think this would be cool.
Best Regards,
Allan Baker