Questions tagged [language-design]

for questions about the design of the Mathematica language itself

Filter by
Sorted by
Tagged with
118 votes
1 answer
2k views

Why are numeric division and subtraction not handled better in Mathematica?

There is something that has been troubling me for a while. At least through version 10.0 the performance of a / b and a - b is ...
Mr.Wizard's user avatar
  • 269k
44 votes
5 answers
2k views

Why is there no PositionFunction in Mathematica?

Too often I have seen the programs of inexperienced users greatly slowed by using Position in an iterative fashion, when far faster would have been to compute a ...
Mr.Wizard's user avatar
  • 269k
16 votes
3 answers
2k views

Specifying string patterns in DeleteCases

It seems that DeleteCases is not compatible with string patterns, at least directly (see, for example, this question). Is this true? If so, why is this the case? ...
Andrew's user avatar
  • 10.2k
48 votes
3 answers
1k views

Is FullGraphics an abandoned function? Is there an alternative?

FullGraphics hasn't worked entirely for a long time and the situation appears to be getting worse instead of better. In Mathematica 10.0, 10.1, 11.3, 12.3 up to 13....
Mr.Wizard's user avatar
  • 269k
43 votes
0 answers
1k views

Performance problems in new Sequence functions

The new-in-10.1 Sequence* family of functions should provide newly optimized methods for handling sequence problems. Happily in some cases they do! For example ...
Mr.Wizard's user avatar
  • 269k
27 votes
2 answers
603 views

Version inconsistency with optional arguments: what if the default value doesn't match the pattern?

I just came across some weird behaviour. Take this function definition: ClearAll[f] f[vs_List : All] := "match" The default value of ...
Szabolcs's user avatar
  • 232k
13 votes
1 answer
393 views

Is there a good reason for the removal of this FrameTicks syntax?

In past versions of Mathematica one could use a terse syntax for FrameTicks: {bottom, left, top, right} In 10.1 this syntax is no longer recognized requiring the ...
Mr.Wizard's user avatar
  • 269k
24 votes
2 answers
666 views

Why doesn't a Composition[] hold its arguments and what can be done about it?

Now that Composition (also RightComposition) has shorthand syntax I am more inclined to use it, however what I feel should be ...
Mr.Wizard's user avatar
  • 269k
19 votes
2 answers
334 views

Association's Attributes change between 10.3.1 & 10.4?

In Mathematica 10.3.1 In[1]:= Attributes[Association] Out[1]= {Protected} In Mathematica 10.4: ...
Gustavo Delfino's user avatar
42 votes
1 answer
2k views

How can I define a new symbolic constant like Pi?

There are a few builtin symbolic constants which behave like numbers, e.g. E, Pi, EulerGamma,...
Szabolcs's user avatar
  • 232k
12 votes
2 answers
318 views

ToExpression and ToBoxes aren't inverses of each other?

Applying ToExpression and ToBoxes repeatedly to Hold[1/1] gives many ...
Bruno Le Floch's user avatar
47 votes
1 answer
5k views

++ is dangerous for C programmers

I noticed this fact, that may be misleading for programmers used to C language. In Mathematica, if you have a function f[] and an array ...
Giovanni Resta's user avatar
38 votes
2 answers
9k views

Why do Mathematica list indices start at 1? [closed]

In most programming languages, container indices start at 0. This is not random or hardware-related; for example Dijkstra's article explains why zero-based indices make sense. What are the reasons ...
Michael's user avatar
  • 757
20 votes
2 answers
467 views

Unexpected behaviour when pattern matching with Longest

I came across some unexpected behaviour today when using the Longest function when trying to do some pattern matching. ...
A Simmons's user avatar
  • 412
16 votes
3 answers
408 views

Why is the first argument of the SetDelayed evaluated?

In[1]: f=g; In[2]: SetDelayed[f[x_],x^2]; In[3]: ?f Global`f f=g In[4]: ?g Global`g g[x_]:=x^2 However, SetDelayed has the ...
XiaoaiX's user avatar
  • 397
88 votes
4 answers
47k views

Why round to even integers?

According to the Mathematica help: Round rounds numbers of the form x.5 toward the nearest even integer. For example: Round[{0.5, 1.5, 2.5, 3.5, 4.5}] gives ...
wxffles's user avatar
  • 14.2k
20 votes
1 answer
740 views

Why won't SparseArray let me store values with the head List?

When you attempt to define a SparseArray with elements that have the head List it complains: ...
Mr.Wizard's user avatar
  • 269k
18 votes
2 answers
5k views

Why does Mathematica order polynomial forms in reverse from traditional order?

I could very well be missing something obvious, but this has always bugged me with Mathematica and I don't know why it does it or how to fix it. If I enter any polynomial, say, x^2 + x - 1 for ...
Brendan's user avatar
  • 525
18 votes
2 answers
1k views

Why it seems that there is no counterpart function as to multiplication, to `Total` as to addition?

Times and Plus have the same grammar, and so do Product and ...
Αλέξανδρος Ζεγγ's user avatar
15 votes
3 answers
5k views

Why don't * and ^ work as I expected on matrices? [closed]

For example, this input... {{1, 2}, {3, 4}}*{{1, 2}, {3, 4}} produces this output... {{1, 4}, {9, 16}} and this input... <...
Harold's user avatar
  • 1,007
13 votes
2 answers
3k views

Why did Mathematica choose brackets for function arguments over parentheses?

This is a non-technical question. I'm just curious why Mathematica breaks the convention that parentheses are widely used for function arguments. What's the advantage of ...
Nick's user avatar
  • 459
4 votes
1 answer
327 views

Why is there a difference when formulating patterns for Select and FirstPosition?

Select[{1, 2, 4, 7, 6, 2}, # > 2 &] Gives {4, 7, 6}. OK! So one should think that the following would work: ...
newandlost's user avatar
47 votes
3 answers
3k views

What are all the "magic" symbols in the Mathematica language?

Leonid Shifrin once wrote (excerpted): (Unevaluated) is one of a very few "magic symbols", along with Sequence and <...
Mr.Wizard's user avatar
  • 269k
22 votes
2 answers
574 views

Second argument of BeginPackage with nested package loading

I naively thought that the second argument of BeginPackage can simply be used to ensure the loading and availability in the ...
Szabolcs's user avatar
  • 232k
15 votes
2 answers
325 views

Is anonymous pure function a scoping construct?

In recent thread was raised the question: why anonymous pure functions Function[body] (or body &) do not rename symbols in ...
Alexey Popkov's user avatar
12 votes
2 answers
278 views

Why is Graph an atomic expression in Mathematica?

Actually, the title says it all. I am a little confused why such a complicated object as Graph, with many different parts, was designed to be atomic in Mathematica ...
Artem's user avatar
  • 1,027
11 votes
2 answers
461 views

Unexpected variable renaming depending on form of a pure function

I encountered unexpected difference in variable renaming behavior depending on whether a pure function with a named parameter, or a pure function with a slot is used: ...
Vladimir Reshetnikov's user avatar
9 votes
1 answer
258 views

Different Set Semantics - Why is assoc["a"] =. different from assoc[["a"]] =.?

Accessing parts of an Association can be done either using Part or the [] extraction ...
Ronald Monson's user avatar
21 votes
1 answer
434 views

Why are some option values symbols, other strings?

Is there a rationale, beyond historical accident, why some Mathematica option values are strings, while others are symbols? It seems natural that some value spaces, e.g. named color schemes, are so ...
alancalvitti's user avatar
13 votes
1 answer
333 views

Why can AppendTo modify a referenced list in-place but Part cannot?

Part, AppendTo, PrependTo, AddTo, etc. allow in-place modification of a list, but only Part requires that the list be referenced through a simple symbol, e.g. the following all does what you'ld expect:...
Eric Parker's user avatar
2 votes
1 answer
176 views

Why does `Position` by default return a list of lists of positions instead of a simple list of positions?

Position[{1,2,3,4,2,3,4,5},2] (* Output: {{2},{5}} *) Why does Position work this way? I understand this form might be ...
Andrew Cheong's user avatar
31 votes
2 answers
2k views

Why did the Mathematica Language choose term rewriting instead of the Lambda Calculus as its basis?

Now we can see that Church was associated with the Simply Typed Lambda Calculus. Indeed, it seems he explained the Simply Typed Lambda Calculus in order to reduce misunderstanding about the Lambda ...
hawkeye's user avatar
  • 429
29 votes
1 answer
1k views

Why some built-in functions are slow

I just wonder why some built-in functions are slower compared to some other ways using more than one built-in functions for doing same job. consider this example: ...
Basheer Algohi's user avatar
26 votes
6 answers
791 views

Is mathematica adequately improving?

A bit of a loaded question, but in your opinion is Wolfram's team making good progress on improving their software? I've used Mathematica for almost 10 years now, and honestly I'm personally ...
Steven Sagona's user avatar
22 votes
1 answer
494 views

What's the difference between these 2 associations?

I have 2 associations similar to these simplified ones: ...
Coolwater's user avatar
  • 19.8k
17 votes
0 answers
209 views

Why are delayed definitions in scoping functions NOT documented?

As outlined here, := may be used in scoping constructs like With to give delayed definitions, but this is undocumented. This ...
Mr.Wizard's user avatar
  • 269k
16 votes
8 answers
3k views

Product of elements of a list

Sum is for functions; Total is for a list. Product is for a function; what is the command ...
user avatar
16 votes
1 answer
591 views

Why doesn't Mathematica pack Boolean arrays?

I've been wondering about this for a while now, so I'm going to ask. This is a question about the design of Mathematica, which perhaps cannot be directly answered by anyone but the designers, however ...
Mr.Wizard's user avatar
  • 269k
13 votes
1 answer
555 views

What naming conventions are used for functions? [closed]

I thought there were patterns to how functions were named, but after looking carefully it seems I can always find exceptions. For instance FindThreshold = Action + Object SetAlphaChannel = Action + ...
M.R.'s user avatar
  • 31k
12 votes
2 answers
877 views

Why aren't parentheses ( ) an expression in Mathematica?

Why aren't parentheses ( ) an expression in Mathematica? Can I get an expression in a form where parentheses are represented by an expression?
user's user avatar
  • 1,857
8 votes
0 answers
145 views

Relation between the syntactic and evaluated Association

This question is inspired by this answer and related to unsolved post "Association's Attributes change between 10.3.1 & 10.4"...
luyuwuli's user avatar
  • 2,764
7 votes
0 answers
194 views

Why patterns names aren't scoped by default?

In a recent question [1] OP asked how to make Module scope working inside Set, so how to get: ...
Kuba's user avatar
  • 136k
7 votes
1 answer
175 views

What is the logiс behind handling alpha-channel by various image-processing functions?

(Cross-posted on Wolfram Community.) When working on the answer to this question I discovered that starting from Mathematica 10.0 the behavior of such functions as ...
Alexey Popkov's user avatar
6 votes
2 answers
532 views

PlotLegends "Expressions" default for ListPlot?

gwr pointed out an apparent problem with setting a default Option value of PlotLegends for DateListPlot. I traced the problem ...
Mr.Wizard's user avatar
  • 269k
6 votes
2 answers
285 views

WL terminology: evaluate, call, invoke, use, etc

A WL (Mma) program is a sequence of expressions to be evaluated, which generally involves applying commands and functions to actual arguments. What is the accepted terminology for what I think of as ...
Alan's user avatar
  • 13.5k
3 votes
1 answer
1k views

Why is Euler's number an uppercase "E" and not a lowercase "e"?

Why is Euler's number an uppercase "E" and not a lowercase "e"? Isn't Euler's Number normally expressed with a lowercase "e"?
Tyilo's user avatar
  • 1,545
44 votes
1 answer
2k views

What's the deal with next generation Wolfram compiler?

Sources: Old Compiler (Rob Knapp Nov2011) Computer Science in Mathematica (Abdul Dakkak Dec2014) Compilation Technology (Tom Wickham-Jones, Abdul Dakkak & Steve Wilson Dec2015) The Wolfram ...
user13892's user avatar
  • 8,973
25 votes
1 answer
780 views

What's the point of ContainsAll, ContainsAny and friends?

Mathematica 10.2 contains a few new functions that test set containment: ContainsAll, ContainsAny and a few others. The ...
Niki Estner's user avatar
  • 35.9k
22 votes
3 answers
4k views

Why does Mathematica use [[ ]] notation for array indexing?

I am confused by why Mathematica uses [[3]] to get the 3rd element, or [[i,j] to get the i,j-th element of a 2D array. This ...
user avatar
22 votes
1 answer
796 views

What are the benefits of Entity Classes for Databases?

To me, using the older database functionality is much simpler: ...
M.R.'s user avatar
  • 31k