Skip to main content

Questions tagged [language-design]

for questions about the design of the Mathematica language itself

Filter by
Sorted by
Tagged with
16 votes
3 answers
422 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
9 votes
1 answer
510 views

Why is Reap result nested? [closed]

A minimal (toy) example for my question: i= 1; Reap[Do[Sow[i = (i + 1)^2], {4}]] (* {Null, {{4, 25, 676, 458329}}} *) I presume the entire result is a ...
murray's user avatar
  • 12.1k
12 votes
1 answer
157 views

Which symbol gets DownValues or OwnValues when using SetDelayed?

I have been looking at various usages of Pattern objects. Here's a number of ways to define the same thing: mod[x_] := {x} ...
LLlAMnYP's user avatar
  • 11.5k
1 vote
0 answers
99 views

What's in a Name? [closed]

StringReplacePart["StringReplacePart","At",{14,17}] ... Surely you can't be serious? ... Naming Matters: I think what and how we call things is ...
Ronald Monson's user avatar
13 votes
1 answer
565 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
  • 31.8k
9 votes
1 answer
271 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
6 votes
2 answers
541 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
  • 273k
0 votes
2 answers
54 views

How to make Mathematica to assemble components we already have like a regular input

Suppose we have the following list: {5, 3} I want to add the -> to the end of the first element in the list in Mathematica ...
Qaher's user avatar
  • 313
26 votes
1 answer
838 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
  • 36.4k
4 votes
1 answer
343 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
14 votes
4 answers
414 views

Association's Key[key] extraction different in V10.1/V10.2

V10.1: <|a -> 1|>[Key @ a] (* Missing["KeyAbsent", Key[a]]*) V10.0: <|a -> 1|>[Key @ a] (* 1 *) Bug or ...
Ronald Monson's user avatar
8 votes
1 answer
1k views

Set PlotTheme globally?

Can one set a default PlotTheme globally? While I recognize one can make lots of workarounds to sort of do this: Go to ...
Jagra's user avatar
  • 14.6k
39 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
  • 767
3 votes
3 answers
124 views

Orderless storage of tabulated function values

I would like to elaborate on my previous question Function of arguments given in non-fixed order and a relevant related one Best practice of passing a large number of parameters to functions I find ...
Rho Phi's user avatar
  • 1,420
6 votes
1 answer
315 views

when two associations are equal?

<|a -> 2, b -> 3|> == <|b -> 3, a -> 2|> returns False; can anybody explain why? If I am not mistaken ...
Rho Phi's user avatar
  • 1,420
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
  • 273k
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
  • 273k
13 votes
2 answers
902 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,897
13 votes
1 answer
400 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
  • 273k
7 votes
4 answers
557 views

Strange answer from StringReplace

I have a list of strings and I would check if there is an empty string element, that's "", because I need to replace it with a "0". I try the following ...
bobknight's user avatar
  • 2,047
12 votes
2 answers
299 views

Why are there a lot of input forms in Mathematica?

I'm a novice in using Mathematica. Please can you explain why there are a lot of input forms in Mathematica such as standard, prefix, postfix and infix?
Igor Fomenko's user avatar
3 votes
0 answers
435 views

Mixing Wolfram Language & WolframAlpha Queries - How robust is it?

The advent of Mathematica in the cloud and linguistic input potentially transforms expectations of the Wolfram Language's programming model and its inherent robustness. An example of this comes form ...
Ronald Monson's user avatar
7 votes
2 answers
314 views

Built in function without Attributes Listable works as if it has Attributes Listable

Can Built-in function works as if it has Attributes Listable even if it doesn't have that ...
Basheer Algohi's user avatar
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
13 votes
1 answer
347 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
8 votes
2 answers
317 views

Why does ToRules return a Sequence?

Why does ToRules return a Sequence expression? Why doesn't it return directly what ...
Szabolcs's user avatar
  • 236k
4 votes
0 answers
1k views

DSolve versus DSolveValue [closed]

I've just discovered the new command DSolveValue in Mathematica 10. Is this new command now the preferred instead of DSolve? Is ...
David's user avatar
  • 15k
11 votes
3 answers
248 views

Lists for built-in functions that can work without brackets

I just noticed that Exit and Quit can work without brackets i.e. a single Exit or ...
xzczd's user avatar
  • 68.4k
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
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
21 votes
1 answer
773 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
  • 273k
24 votes
2 answers
698 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
  • 273k
4 votes
1 answer
206 views

Why even try the semantic constraints, if expression can't match the pattern structure?

This result is unexpected: Trace[MatchQ[{7}, {_?NumberQ, __}], NumberQ] (* -> {{NumberQ[7], True}} *) Why evaluate NumberQ...
Fallible's user avatar
  • 793
6 votes
1 answer
380 views

Why does Mathematica list the variables in a double integral backwards?

I am an advanced novice Mathematica user and have done a fair amount of single-variable calculus things with it. This semester I am using Mathematica for multi-variate calculus and when I tried to ...
Glenn's user avatar
  • 61
3 votes
1 answer
159 views

Why is left NumberPadding always applied in NumberForm?

I would like to display numbers like 9.0001 and 10.0001 in the fixed-width form of xx.xxxx. ...
ArgentoSapiens's user avatar
120 votes
1 answer
3k 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
  • 273k
20 votes
2 answers
6k 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
  • 545
8 votes
1 answer
2k views

why mathematica outputs "True" sometimes in outputs that are conditional to mean "in all other cases"? [closed]

consider this simple Input: Probability[g <= m && m <= -g + 1, {m, g} \[Distributed] UniformDistribution[{{0, 1}, {0, gg}}]] which generates a ...
Emilio Calvano's user avatar
45 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
  • 273k
21 votes
1 answer
448 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
  • 15.2k
3 votes
1 answer
2k 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,565
17 votes
1 answer
617 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
  • 273k
17 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.5k
22 votes
3 answers
5k 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
21 votes
1 answer
583 views

Are there advantages to using additional arguments of common functions rather than alternative ways of calculating with lists?

(Apologies for the long question title.) One of the interesting, if sometimes confusing, things about Mathematica is that there is always more than one way to do things. Even intermediate users can ...
Verbeia's user avatar
  • 34.5k
9 votes
1 answer
298 views

DiracDelta attributes

Is there any reason why DiracDelta isn't a NumericFunction but DiracComb is? I just ate a ...
Rojo's user avatar
  • 42.8k
88 votes
4 answers
49k 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.3k
16 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,017

1 2
3