157k 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 ...
2k views

### Is there a name for #1@#2&?

Why does the pure function # @ #2 & have no name? I'm asking because sometimes I find inelegant to write expressions like ...
• 137k
7k views

### How to deal with recursion formula in Mathematica?

In engineering problems, I am always seeing many recursion formula. For instance, In the book "The NURBS book", I discovered many recursion formula Fibonacci f(...
• 625
2k views

### Is it possible to reference "self" from a pure function?

This would calculate the factorial of 6, if the "self" was the function itself. Is there something that could allow this? ...
• 1,897
2k views

### What is the most efficient way to map a linked list?

In order to work with lists effectively using common recursive patterns from functional programming, it's often most convenient to worked with the "linked list" representation, that looks like this: <...
• 18.5k
879 views

### How to pass a list of arguments into HoldAll

I have a list of arguments (which in reality is lengthy): arguments = {a, b, c} arguments2 = {a_, b_, c_} f[Sequence@@arguments2] := a + b + c Note: It seems ...
• 1,217
370 views

### String templating

I am pretty new to string processing in Mathematica. But I'm having some problems in doing simple string template filling to my mind elegantly. For example when doing export for my answer here, one of ...
• 790
1k views

### Display level of recursion of a recursive function during execution

Given a recursive function, is there some simple way to display or store the value of recursion or "how many levels deep" the function is at a given time? For instance, if we wrote the recursive ...
• 901
1 vote
3k views

### How do I define a function that uses a recurrence relation? [duplicate]

I know how to define functions other than the ones that use a recurrence relation to calculate the $n$-th term of a sequence. How would such a function be constructed?
1 vote
2k views

### Why do I get an error message when for this type of recursion?

When I type the following code: mus[] = 0; mus[x__] := First[List[x]] + mus[Rest[List[x]]] What one would think would happen is that if, ...
180 views

### Recursion and safety of SetAttributes[Function, SequenceHold]

Compare the timings below N@Timing@Block[ {iii = 0}, Nest[ {#[[1]] + 1, Plus[#[[1]], 1, (#[[1]] + 1)*#[[2]]]} & , {0, 1}, 5000 ] ] ...
• 12.2k
1 vote