118
votes
Why should I avoid the For loop in Mathematica?
If you are new to Mathematica, and were directed to this post, first see if you can use Table to solve your problem.
I have often told people, especially beginners,...
43
votes
What are the most common pitfalls awaiting new users?
The default $HistoryLength causes Mathematica to crash!
By default $HistoryLength = Infinity, which is absurd. That ensures ...
Community wiki
41
votes
What are the most common pitfalls awaiting new users?
Using Sort incorrectly
Sorting mathematical expressions without numeric conversion
New users are often baffled by the behavior of ...
Community wiki
34
votes
Accepted
What are the requirements for a well behaved indexed variable? Subscript, ToExpression, Downvalue?
General usage
Here is what I think
Using strings and subsequently ToString - ToExpression just to generate variable names is ...
33
votes
Why should I avoid the For loop in Mathematica?
Illustration of the timings required to compute the squares i^2 from i=1 to i=10^n for ...
Community wiki
33
votes
Accepted
Why it seems that there is no counterpart function as to multiplication, to `Total` as to addition?
In addition to the previous answer...
I designed and implemented Total 17 years ago. Its first version was named ListSum. The ...
32
votes
Accepted
++ is dangerous for C programmers
I believe Increment (more accurately PreIncrement as george2079 noted) is essentially this:
...
29
votes
What are all the "magic" Symbols in the Mathematica language?
uh oh, another "work in progress" answer from me that may never be finished.
Unevaluated
Robby Villegas, Working with Unevaluated Expressions:
...
27
votes
What are the most common pitfalls awaiting new users?
Why do I get an empty plot?
Often new Mathematica users (and some not-so-new users) post questions asking why their plot of some expression just shows axes, with no plotted curve appearing. The key ...
Community wiki
27
votes
What is the use of FullForm in Mathematica?
Perhaps there are other uses, but I've primarily used FullForm to "see" what Mathematica "sees". This can be useful when you are trying to do replacements on ...
27
votes
Difference between HashTable datastructure and Association datastructure
Summary
Important differences between Association and CreateDataStructure["HashTable"] include:
associations are ...
26
votes
Resolving my Entity* Crisis
As an employee at Wolfram who is partly involved with development of the entity framework, let me give my take on things. Particularly, I want to address the following points raised by the OP and in ...
25
votes
Accepted
How can one manually change the rule ordering
General
The definitions get reordered at definition-time by a part of the pattern matcher, that takes care of automatic rule reordering. It does so, based on relative generality of rules, as far as ...
25
votes
Unexpected behaviour from Table[]
This is just a long comment trying to shed light on where the problem may be coming from.
Since version 10.2, the following is valid syntax:
Table[x, 5]
Before ...
25
votes
Learn Mathematica (Wolfram) Language in one day
I would recommend these two, in the order listed:
Wolfram Language: Fast introduction for
programmers
Besides the generic edition, there are currently two special editions of this tutorial available ...
24
votes
Accepted
Around usage results
There's a subtlety here.
When operating together multiple Arounds, the two uncertainties will be considered separate and independent (in the statistical sense). ...
24
votes
Accepted
Row vectors and column vectors (Mathematica vs. MATLAB)
This is a limitation of MATLAB, as MATLAB is only able to work with matrices. It does not have true vectors. It cannot even represent a character array as a 1D array or a structure array as a single ...
24
votes
Accepted
A clean way to conceptually extract Parts from a circular list
Perhaps ArrayPad:
ClearAll[f1]
f1 = ArrayPad[##, #] &;
Examples:
...
24
votes
Accepted
What's the difference between these 2 associations?
Preamble
The real problem here seems somewhat deeper than what the (mostly correct) observations in comments indicate. In Mathematica, a number of objects, which are so-called raw objects (including ...
23
votes
What are the most common pitfalls awaiting new users?
Misunderstanding Dynamic
Although this FAQ is to "focus on non-advanced uses" and Dynamic functionality is arguably advanced it ...
23
votes
What are the most common pitfalls awaiting new users?
Use Rasterize[..., "Image"] to avoid double rasterization
[UPDATE: starting from version 11.2.0 Rasterize[...] defaults to <...
Community wiki
23
votes
Accepted
Why use pure functions?
Think of it as a macro.
It shortens up your code.
It stops your namespace from being polluted with extra function definitions.
In some cases it can be faster than defining an auxiliary function.
I ...
22
votes
How can one manually change the rule ordering
Actually we have direct control over this via a System Option. Set:
SetSystemOptions["DefinitionsReordering" -> "None"];
Then:
...
22
votes
Accepted
Version inconsistency with optional arguments: what if the default value doesn't match the pattern?
Update: Daniel Lichtblau authoritatively comments:
This change was intentional, and per request of the boss.
I can find no mention of this in the documentation, though I am still looking. My ...
21
votes
Accepted
Using Sequence to delete a part of an expression
What happens to the list after we assign an element to Sequence[]
The answers given so far already contain most of the pieces needed to explain this behavior, but I ...
21
votes
Accepted
PostScript-like drawing in Mathematica?
As J.M. notes in a comment, AnglePath allows paths to be specified in relative terms instead of absolute terms:
...
21
votes
Accepted
Getting the "root" Head
With a few functions to try, defined in differentfunctions, try this headF:
...
20
votes
What are the most common pitfalls awaiting new users?
Fourier transforms do not return the expected result
Many users know a particular definition of the Fourier transform. When Mathematica returns an unexpected result and users cannot comprehend what ...
Community wiki
20
votes
Accepted
What is a function?
A function is really a mathematical idea. In Mathematica, we can represent, or denote, a function in a few ways. But Mathematica is really working with expressions.
...
18
votes
Is there a "precedence table" for the canonical Sort ordering?
So I think the docs are mostly clear, if hard to visualize. Here's my version of such a table:
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
core-language × 567functions × 59
list-manipulation × 50
language-design × 40
function-construction × 36
pattern-matching × 35
evaluation × 33
programming × 31
syntax × 29
scoping × 20
replacement × 15
functional-style × 14
expression-manipulation × 13
bugs × 12
associations × 12
variable-definitions × 12
plotting × 11
numerics × 11
built-in-symbols × 11
hold × 9
symbols × 9
equation-solving × 8
performance-tuning × 8
documentation × 8
assignment × 8