# Questions tagged [coding-style]

Questions on how to write code in a better or different style, using Mathematica's capabilities for coding in multiple styles.

145 questions
Filter by
Sorted by
Tagged with
387 views

### Smart way to remove rules from lists, leaving just values, specifically from FindMinimum output

I would like to know if there is a direct way to remove the rules from a list of rules. I know that, simply, this can be done with: ...
289 views

### How can I efficiently define functions with different names but doing the same stuff?

Recently I have met with with this interesting question:How can I efficiently define functions with different names but doing the same stuff? Somebody may want to ask me why I want to do things like ...
• 289
43 views

### How to organise definitions that contain named parameters

I have lots of definitions of (usually numeric) quantities that depend on parameters; they're mostly matrices (in the actual code, there are many more definitions): ...
• 205
88 views

• 199
95 views

### Why is my version of Euler's Method not working?

I am creating Euler's method for $\frac{dw}{dt}=(3-w)(w+1)$ for $\Delta t=0.5$ from $0\le t \le 3$. I tried the following. ...
• 199
87 views

### How can I make this "Pick" inside a "Table" run faster?

I am working on becoming more and more familiar with MMA and on a scale from one to ten, I would rate myself as a four or a five. I understand vectorization and that loops-are-very-bad. I have ...
• 161
233 views

### Extract outputs from a WHILE loop in a table format

How can I convert my multiple outputs of a while loop in a table form and save it for later use. Here is a sample code: ...
771 views

### Map vs. Table for index-specific operations on 2D arrays

Many experienced users on this site tend to use Map (and its variants, MapAt, MapIndexed, etc.) rather than Table. When applying the same operation to every element of an array, Map does seem more ...
• 3,446
1 vote
31 views

### RecursionLimit errors on Manipulate a DensityPlot expression

I am trying to do an interactive visualization of a very simple neural network (inspired by tensorflow playground): ...
• 113
84 views

### Design Patterns for System Functions?

Using PrintDefinitions give one a great view into many system functions. Often the design of these symbols incorporate multiple patterns that I see again and again. ...
• 30.3k
868 views

### Angle increment spiral in Mathematica

What method cold I use to obtain a Plot similar to the one in the picture?
• 111
105 views

### How to improve on this Stylesheet Manipulation for Message Styling

The answer by @Kuba changing color of error messages did not seem to work for me (MMA 11.0.1 Win 10 64-bit). I couldn't work out why and implemented something else that does work for me, but it seems ...
• 2,410
158 views

### How to safely forward/manage options between functions?

Algorithms can often be splitted into smaller and reusable functions (that's a good thing). However with this scheme it is not clear to me how to ensure the consistency of the option values and ...
• 2,383
1 vote
44 views

### Generic symbols vs Generic functions arguments [closed]

I've got a lot recursion relation that takes multiple hours at a time to run. I'm looking for some subtle reasons why it takes so long, and hoping to be able to reduce the time it takes for the more ...
• 135
72 views

### Good habits for handling intense computations with mathematica

I always used mathematica for more "theoretical" computations: maybe I had to handle intricated manipulations, but things that you could almost do on paper. Now I just joined a new project where we ...
71 views

### Another for loop question: efficiency versus readability

I have some sorted data: data = Sort[RandomInteger[{0, 15}, 10]] and I want to generate a duplicate array where a counter is ...
• 2,383
660 views

### Can we turn this for loop into a more elegant Mathematica code?

I am coding stuff manipulating indirection arrays and I have some code like: ...
• 2,383