Linked Questions

314
votes
12answers
60k views

Where can I find examples of good Mathematica programming practice?

I consider myself a pretty good Mathematica programmer, but I'm always looking out for ways to either improve my way of doing things in Mathematica, or to see if there's something nifty that I haven't ...
79
votes
7answers
7k views

Struct equivalent in Mathematica?

I really miss having something like a struct in Mathematica. I know of (and regularly use) a couple of programming techniques which feel like a ...
88
votes
5answers
7k views

How to compile effectively?

What are the best practices of compiling functions? I understand that this is a vague question, but let me list some aspects that might trigger useful answers. Some of these have already been answered ...
37
votes
4answers
2k views

How do I evaluate only one step of an expression?

I am looking for a simple, robust way to evaluate an expression only one step, and return the result in a held form. The definition of a single step is ambiguous, and this itself is probably worthy ...
24
votes
7answers
496 views

What kinds of uses of SymbolicC (introduced in Mathematica 8) do you foresee? Are there any neat examples already?

Mathematica 8 introduced SymbolicC, a set of Mathematica functions that capture C language constructions in the familiar Mathematica tree-like fashion. Additionally, there are functions to write ...
17
votes
2answers
603 views

How to inject an evaluated expression into a held expression? [duplicate]

I know that there are methods to structurally manipulate held expressions (discussed e.g. here), but I failed to apply those for this particular problem: ...
7
votes
6answers
200 views

How to join held Lists?

Let's say I have a = Hold@{2+2} b = Hold@{4+4} How can I get Hold@{2+2,4+4} ie join the two held lists ? More ...
12
votes
2answers
508 views

How can I compile this function

I want to simplify my function f1 to f2, but f2 can't be compiled. How can I make it ...
9
votes
1answer
388 views

Compile function which calls other functions to C

I have a function which calls other functions and I would like to compile it to C code. For example: ...
11
votes
1answer
313 views

Using Apply inside Compile

In this great answer a compiled version of the Nelder-Mead algorithm is presented. Since it works on arbitrary dimensions (i.e. arbitrary number of arguments), it has to use apply on the objective ...
7
votes
1answer
313 views

CompilationTarget->“C” crashes the kernel

Major deviation from my original post I realize that the long code I originally had was very discouraging to debug and did not attract any answers. So I have decided to revamp this question ...
5
votes
1answer
192 views

How to use Compile to efficiently apply a function to every element of a list

Let's say I have a list of random numbers; list = Table[Random[], {100000}]; I want to apply a function f in every element of ...
1
vote
1answer
244 views

Compile with array operations

When I use the function f with only the Module ...
2
votes
1answer
71 views

How to make the code inside Compile conciser without hurting performance?

Consider the following sample: ...