Questions tagged [language-design]

for questions about the design of the Mathematica language itself

Filter by
Sorted by
Tagged with
11
votes
2answers
237 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 ...
11
votes
2answers
494 views

Why is IdentityMatrix not defined as a SparseArray by default?

Simple (possibly silly) question: why are IdentityMatrix, DiagonalMatrix, ConstantArray ...
11
votes
2answers
242 views

Why and how does RuleDelayed evaluate to itself?

It seems that RuleDelayed has some behaviour we cannot reproduce. It is not just a symbolic wrapper. Consider this: ...
11
votes
2answers
227 views

ToExpression and ToBoxes aren't inverses of each other?

Applying ToExpression and ToBoxes repeatedly to Hold[1/1] gives many ...
10
votes
3answers
202 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 ...
10
votes
1answer
226 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 ...
9
votes
1answer
206 views

Why can I define N[MySymbol] := …?

As far as I understand, I cannot define the values of built-in functions: Sin[Cat] := Dog will result in error. This is because all built-in symbols have attribute <...
9
votes
1answer
426 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 ...
9
votes
1answer
277 views

DiracDelta attributes

Is there any reason why DiracDelta isn't a NumericFunction but DiracComb is? I just ate a ...
9
votes
0answers
94 views

List assigment ({…}={…}) and UpValues

Let's say I want to track any assignment attempt for a variable a: a /: Set[a, x_] := Print@{a, x} This works as intended: <...
8
votes
2answers
349 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: ...
8
votes
1answer
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 ...
8
votes
2answers
230 views

Why does ToRules return a Sequence?

Why does ToRules return a Sequence expression? Why doesn't it return directly what ...
8
votes
0answers
101 views

What is the philosophy behind \[Rule] (a.k.a. `->`) for assigning options?

Today I was banging my head against my desk when I realized that the problem I was experiencing was due to having typed ImageSize[Large] instead of ...
8
votes
0answers
135 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"...
7
votes
4answers
524 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 ...
7
votes
2answers
279 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 ...
7
votes
1answer
106 views

Why does `SameQ` act inconsistently with `Image`s wrapped in `{}` versus not?

Take an Image that is displayed in a GraphicsBox, e.g. the result of ...
7
votes
1answer
629 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 ...
7
votes
1answer
156 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 ...
7
votes
1answer
96 views

A bug and inconsistency in current image arithmetic operations?

Let us start from a single-pixel RGBA image: i = Image[{{{0., .4, .7, .8}}}, Real, ColorSpace -> "RGB"]; Multiplying by .5 ...
6
votes
3answers
483 views

Is $2x$ documented?

According to the official documentation of Times[], multiplication of $x$ and $y$ is represented as one of x*y x×y ...
6
votes
2answers
899 views

Line by line code development

One main advantage of Mathematica over several other languages, at least in my view, is that you can create your code line by line. This makes much easier to debug your code during the development ...
6
votes
2answers
211 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 ...
6
votes
3answers
248 views

why does Function have the HoldAll attribute?

Consider the following: f = 2 # & OwnValues[f] g = f[#]/2 & OwnValues[g] Since Function has the ...
6
votes
2answers
139 views

Separation of statements vs “space mul”, formal definition of Mathematica syntax?

In Mathematica, space can often be used to indicate multiply. For example "a b" = "a * b". On the other hand, in a *.m file, we also have multiple statements separated by newlines. How does the ...
6
votes
2answers
394 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 ...
6
votes
1answer
84 views

Counterintuitive DownValue precedence

Consider the following definitions for two symbols: foo[a] /; True := b foo[a] := a foo[a] (* a *) foo2[a_] /; True := b foo2[a_] := a foo2[a] (* b *) (The ...
6
votes
1answer
154 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 ...
5
votes
1answer
554 views

What is not an expression in the Wolfram Language? [closed]

Everything Is an Expression, or In fact, everything you type into the Wolfram Language is treated as an expression. The cool cliché confused me for a long time. The following two statements are ...
5
votes
1answer
177 views

What is the point of StringForm?

I never really understood the point of StringForm returning a StringForm rather than a String...
5
votes
1answer
65 views

Missing[“reason”]—can any reason be used?

Can any string be used as a "reason"? Or is there a specific list of acceptable reasons? For instance, Missing["refuse"] works as a missing? Is there any ...
5
votes
1answer
80 views

Making an Association-like interface for HashTable

System`Utilities`HashTable is conceptually a lot like an Association but it has the pretty phenomenal (for Mathematica) property ...
5
votes
0answers
57 views

Why ReadList ignores NullRecords for Number?

When thinking on this recent question the immediately obvious solution which came to my mind was to use ReadList with options ...
5
votes
0answers
156 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: ...
5
votes
0answers
204 views

Is there an internal logic behind short form symbols, such as @ (Prefix), @@ (Apply), /@ (Map), /. (ReplaceAll) [closed]

To me, function names (such as Apply and Map) seem more intuitive than their symbols (e.g. @@...
5
votes
0answers
170 views

Learning the Wolfram Language ‘from the bottom up’ [duplicate]

I'm a armchair programming-language theorist, and I know … quite a few programming languages, some to extensive depths. (Hell, I've built more than my fair share.) Most of the information I've found ...
4
votes
1answer
252 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: ...
4
votes
1answer
169 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 ...
4
votes
1answer
60 views

A natural syntax for a Query that holds

Often I have an unevaluated expression in a RuleDelayed Key-Value pair and subsequently want ...
4
votes
1answer
179 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...
4
votes
0answers
74 views

Obtain complete list of built-in graphical objects, and split them into groups?

I would like to obtain the complete listing of built-in graphical objects (which can be used in Graphics or Graphics3D) ...
4
votes
0answers
66 views

Why is SparseArray atomic?

This answer tells us that functions like ReplaceAll do not straightforwardly work for the entries of sparse arrays because a ...
4
votes
0answers
150 views

Specifying a region of the complex plane [closed]

I can use the following to specify a region of the complex plane. R1=ImplicitRegion[1.0<=Norm[{a+1,b-1}]<=2.0,{a,b}]; RegionMember[R1,{0.5,1}] It would be ...
4
votes
0answers
813 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 ...
3
votes
1answer
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"?
3
votes
3answers
111 views

Why Graph does not recognize chains of vertexes like NetGraph

Cross posted on Wolfram Community. Perfect logic: NetGraph[{1, 1, 1}, {1 -> 2 -> 3}] But this does not make sense: ...
3
votes
1answer
74 views

Understanding how List head works

I am trying to understand how Wolfram Language is actually meant to work and here is something that I fail to understand. Apply[f, expr] replaces the head of expr by f. So how come I get different ...
3
votes
3answers
109 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 ...
3
votes
2answers
295 views

Module inside Module. Conflict of names in arguments

I have a module which calls number of other smaller helper modules. But those other helper modules are not used by another module, so there is no needed to have them in global context. So I wanted to ...