# Tag Info

Accepted

### Metaprogramming: creating compiled functions from inter-dependent code blocks

To compose code from blocks you could use simple quoting mechanism like following: ...
• 15.1k
Accepted

### Converting Piecewise function to C code

-10 < x < 0 // LogicalExpand // CForm (* -10 < x && x < 0 *)
• 67.7k
Accepted

### Compute Hessian of function symbolically

I think this should be fine, the full form doesn't look neat with x\$123 etc but that doesn't matter: ...
• 137k
Accepted

### Easy code help about matrix. How to change the elements in a given matrix?

Have a look at ReplacePart[] A[1, 1] = {1, 2, 3, 4}; ReplacePart[A[1, 1], 2 -> 5] {1, 5, 3, 4}
• 1,441
Accepted

### How to get a peek at the source code for demonstrations if there is no source code provided

One method that I think works is to highlight the demonstration, copy it to a new Mathematica notebook, and then click "Convert to Input Form" on the cell.
• 10.2k

### Christmas fun with Mathematica

Nothing groundbreaking, but a quick composure of some graphics objects: ...
• 4,302

### Metaprogramming: creating compiled functions from inter-dependent code blocks

You already have a very good and general answer for your question. Just for completeness I wanted to show you an alternative which is much less general but shows that there is actually not too much ...
• 23.6k

### Compute Hessian of function symbolically

Is this not a good place to use Formal Symbols? A number of built-ins do that.(1) ...
• 273k
Accepted

### Understanding code generated by MicrocontrollerEmbedCode

The value 84.38063590995105=-26.8592*π is a residue that pops up if the equilibrium value is not set correctly. There are a few things that need to be changed to ...
• 8,806

### How to generate input cells whose code is determined dynamically?

You should just use With instead of Module, as Carl Woll suggests in the comments: ...
• 62.1k
Accepted

### Is it possible to automate definitions given with TagSetDelayed?

You mean something like: ...
• 24.3k
Accepted

### How to convert any string of code to an input cell?

TLDR: FrontEnd will happily accept an input form string wrapped with BoxData: ...
• 137k

### Stepped Infinite Square Well

Having solved the problem with writing the potential, you may use "Eigensystem" to solve this problem (with arbitrary numerical values): ...
• 54.6k

### SymbolicCCSwitch basically broken?

The documentation for CSwitch looks like it was written by somebody who didn't understand what the SymbolicC package or, for ...
• 108k

### Write Power in CForm[] as multiplication instead

You can override the default CForm handling of Power as follows: ...
• 131k

### NDSolveValue solutions differ based on number of equations

General reasons for a difference There are (at least) two differences why solving independent systems with one call might result in different solution than solving them separately: Independent vs. ...
• 241k
Accepted

• 67.7k

### How to programmatically modify a function definition

This is my first time wading into metaprogramming in Mathematica, so take this with a pinch of salt. I can get the DownValues of ...
• 25.6k
Accepted

### How to programmatically modify a function definition

To operate on notebooks Let nb be the notebook you want to alter obtained with NotebookGet[]. For instance, it could be ...
• 241k

### How to generate input cells whose code is determined dynamically?

This required a bit more trickery than I would like: ...
Accepted

One way: ...
• 71k

### How can I automatically generate usage messages?

Here's a partial implementation, working from the DownValues and friends: We start with a bunch of DownValues cleaning: ...
• 47k
Accepted

### Optimizing an expression – find identical subexpressions and substitute them

As I noted in my comment above, the undocumented (thus, caveat emptor as usual) method is to use ExperimentalOptimizeExpression[]: ...

### SymbolicC namespace?

Have you looked at the builtin documentation? SymbolicC User Guide The introduction – C++ section clearly states: At present, SymbolicC only supports C syntax. That is, it does not support C++. ...
• 236k

### Metaprogramming: creating compiled functions from inter-dependent code blocks

I came up with my own way of dealing with this. I'm not sure if it's the simplest way. I was careful to make sure I dealt with all possible namespace issues, as well as possible recursive calls ...
• 278

### Write Power in CForm[] as multiplication instead

If the symbol you are using is known in advance, you can useTagSetDelayed and associate an UpValue with that symbol inside the <...
• 4,225

### Applying And to a list inside a Function

For the exact expansion that you show: Replace[And[1, 3, 7, 9, 13, 27] &, x_ :> PrimeQ[# + x], {2}] ...
• 273k

### OptimizeExpression to C code

So since I need it, I wrote the function myself. It is a little bit hackish approach, but it solves my problem. So any comment and suggestions for improvement are welcome. ...
• 295

### How to programmatically modify a function definition

That's not a real answer... But I failed to format it as a comment. Again. You're opening a deep can of worms now, called "metaprogramming". Please search for "metaprogramming" and ...
• 1,345