170 votes
Accepted

How to make use of Associations?

I. General I will first try to briefly answer the questions, and then illustrate this with a small but practical application. 1.Speed of insertion / deletion Associations are based on so called Hash ...
user avatar
114 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,...
user avatar
  • 227k
74 votes
Accepted

Incompatible Changes since Mathematica Version 7?

Prelude The items in this post are not generally regressions; they are simply changes and enhancements that may break code or cause problems in moving from one version to another. The work-arounds ...
56 votes

What are the most common pitfalls awaiting new users?

Don't leave the Suggestions Bar enabled The predictive interface (Suggestions Bar) is the source of many bugs reported on this site and surely many more that have yet to be reported. I strongly ...
49 votes

How to make use of Associations?

I helped design Association, and I designed and implemented Dataset, so I wanted to comment on question 3: Dataset is designed ...
user avatar
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 ...
42 votes
Accepted

Why is the new PositionIndex horribly slow?

First let me note that I didn't write PositionIndex, so I can't speak to its internals without doing a bit of digging (which at the moment I do not have time to do)....
user avatar
41 votes
Accepted

What's the difference between Inactive and HoldForm?

Updated Both Hold and Inactive block evaluation; the key difference is that Inactive is ...
user avatar
  • 8,382
40 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 ...
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 ...
user avatar
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 ...
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 ...
user avatar
32 votes
Accepted

++ is dangerous for C programmers

I believe Increment (more accurately PreIncrement as george2079 noted) is essentially this: ...
user avatar
  • 265k
31 votes
Accepted

Why some built-in functions are slow

The general case There are indeed some functions in Mathematica that are/were not performing nicely. The one I am most scared of is Total (the issue is addressed ...
user avatar
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: ...
user avatar
  • 265k
28 votes
Accepted

Shorter syntax for Fold and FoldList?

Good News Everyone! Two-parameter syntax for Fold and FoldList has been (silently) implemented! Taliesin Beynon informs me that ...
user avatar
  • 265k
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 ...
27 votes
Accepted

How to completely delete the head of a function expression

You can actually Delete the head of the expression, which is part 0: ...
user avatar
  • 265k
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 ...
user avatar
  • 9,961
26 votes

Difference between HashTable datastructure and Association datastructure

Summary Important differences between Association and CreateDataStructure["HashTable"] include: associations are ...
user avatar
  • 67.3k
25 votes
Accepted

Why is Query so much slower than Part?

Let's start by taking a look at the compiled form of one of our queries: ...
user avatar
  • 67.3k
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 ...
user avatar
  • 227k
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 ...
user avatar
  • 68.9k
24 votes

How to make use of Associations?

First of all, it's not a new data structure, it's a new only in a Wolfram Mathematica. About complexity of a data structure. It's a Wolfram implementation of a hash-map. With a complexity of an ...
user avatar
  • 3,817
24 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 ...
user avatar
  • 847
24 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 ...
user avatar
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). ...
user avatar
  • 227k
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 ...
user avatar
  • 227k
24 votes
Accepted

A clean way to conceptually extract Parts from a circular list

Perhaps ArrayPad: ClearAll[f1] f1 = ArrayPad[##, #] &; Examples: ...
user avatar
  • 350k
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 <...

Only top scored, non community-wiki answers of a minimum length are eligible