Questions tagged [language-design]

for questions about the design of the Mathematica language itself

16
votes
1answer
235 views

What are the benefits of Entity Classes for Databases?

To me, using the older database functionality is much simpler: ...
6
votes
2answers
108 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 ...
3
votes
3answers
103 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: ...
1
vote
0answers
64 views

Is there packages can help read, analyze or understand MMA codes? [closed]

Sometimes, I think that it's difficult to learn high level codes, or even when looking back on some long lines of codes I myself had written, espectially when lots of pure-functions was used, so I'm ...
5
votes
1answer
75 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 ...
8
votes
0answers
92 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 ...
2
votes
1answer
76 views

DeleteCases not working as expected

I am trying to reproduce the example of Data Cleaning from here. I had to make a slight change in input 13 to ...
6
votes
1answer
78 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 ...
19
votes
4answers
925 views

Is expression in Mathematica well defined?

According to Mathematica, everything is an expression. So an atom is also an expression. But in other parts of documentation, they say that an expression is of form ...
2
votes
0answers
78 views

Areasinus hyperbolicus [closed]

Why is there a function ArcSinh[]? Shouldn't this be called ArSinh, since it is connected with an area and not with the length (...
7
votes
1answer
150 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
92 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 ...
9
votes
0answers
81 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: <...
4
votes
0answers
60 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 ...
3
votes
2answers
211 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 ...
1
vote
2answers
122 views

Why can we assign a value to a function that has not been defined yet?

Consider the following snippet, fib[1] = fib[2] = 1; fib[n_Integer] := fib[n - 1] + fib[n - 2] As a newbie, it seems for me, the first line assigns 1 to ...
5
votes
2answers
189 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 ...
3
votes
1answer
111 views

Single argument operator form?

I've heard the explanation that functions like StringDrop[] are varargs and so that is why they do not have an operator form. But when you are only using the ...
5
votes
0answers
53 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 ...
3
votes
1answer
96 views

Span starting from the end

I could not find something similar. Given, e.g. lst = Range[10] (* {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} *) the following gives the reverse of ...
8
votes
1answer
197 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 <...
12
votes
1answer
203 views

Code indenting of // postfix functions

(This question may fall into the "primarily opinion based" category, in which case it should be closed. I shall try to make it sufficiently focused but I expect no special treatment. I anticipate ...
4
votes
0answers
128 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 ...
5
votes
1answer
538 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 ...
12
votes
1answer
258 views

Why isn't Orderless an Attribute of And?

In standard logic And is a commutative operator. Still, in Mathematica, And doesn't have the ...
39
votes
1answer
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,...
13
votes
0answers
107 views

Why does MapAt unpack individual elements?

(In case this is version specific I am using Mathematica 10.1 under Windows.) While responding to Partition array without unpacking I noticed something about MapAt ...
8
votes
2answers
202 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 ...
2
votes
0answers
62 views

Why does Mathematica round numbers in this way where the fractional part is 0.5? [duplicate]

I was trying to comment on sequence https://oeis.org/A047229 in the OEIS, when one of the editors pointed out that the rounding is done wrong in this Mathematica one-liner: ...
2
votes
2answers
97 views

Sets of identical equality/inequalities

So I've used Mathematica for some months, but I never noticed this sort of thing about it, namely: (a > b) == (b < a) which are supposed to be identical ...
32
votes
1answer
558 views

The paradigm behind Dynamic and related functionality

Dynamic and the related functionality strikes me as a very unique way to build quick and dirty personal GUIs which are great for experimentation. I suspect that ...
6
votes
3answers
220 views

why does Function have the HoldAll attribute?

Consider the following: f = 2 # & OwnValues[f] g = f[#]/2 & OwnValues[g] Since Function has the ...
8
votes
0answers
128 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"...
5
votes
1answer
147 views

What is the point of StringForm?

I never really understood the point of StringForm returning a StringForm rather than a String...
1
vote
2answers
142 views

inappropriate domain restriction on FromPolarCoordinates?

The only way I can understand the domain restriction on FromPolarCoordinates is as ensuring a round-trip is possible: ...
18
votes
2answers
303 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: ...
14
votes
2answers
233 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 ...
8
votes
2answers
313 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: ...
11
votes
2answers
240 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: ...
7
votes
1answer
105 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 ...
15
votes
0answers
178 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 ...
41
votes
2answers
2k 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 ...
27
votes
2answers
1k 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 ...
5
votes
0answers
147 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: ...
3
votes
1answer
163 views

Refactoring: Why? When? How?

A good Refactoring can transform a kludgy WL code-base into a thing of pristine coherency but how to do so consistently?
11
votes
2answers
456 views

Why is IdentityMatrix not defined as a SparseArray by default?

Simple (possibly silly) question: why are IdentityMatrix, DiagonalMatrix, ConstantArray ...
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 ...
20
votes
2answers
399 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 ...
2
votes
1answer
105 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 ...
3
votes
0answers
119 views

Why is MeshRegion atomic?

I wanted to make some changes inside a MeshRegion today and found that unlike Graphics objects, it can't be done directly ...