All Questions
Tagged with language-design core-language
40 questions
1
vote
0
answers
56
views
Why do rules not default to local scope? [closed]
Consider the following:
80 //. a_?EvenQ -> a/2
a = 3
80 //. a_?EvenQ -> a/2
which outputs:
5
3
3/2
I think I understand ...
7
votes
2
answers
381
views
Why do some functions require its arguments to be in a list while others accept these as a sequence? [closed]
With Midpoint[{{4, -2}, {2, 5}}], the vectors must be in a list.
But with EuclideanDistance[{-2, 2}, {3, -6}], they don't.
These ...
4
votes
2
answers
230
views
What should mapping over a number or symbol produce?
I expected it to be an error (i.e., produce an error message), but Map[f,num] is num. Why is this the correct behavior? If it is ...
4
votes
1
answer
332
views
Differences between minimization functions?
There's more than 20 functions having to do with minimization
...
0
votes
1
answer
533
views
Keywords for the Wolfram Language [closed]
For a programming language, certain keywords are reserved; i.e., these tokens can't be used in any other context while programming in that particular language.
Here is a list of C language keywords ...
1
vote
0
answers
152
views
Intervals v.s. Domains: when to use which and why?
or: How to use Interval correctly?
Mathematica provides these constructs for various symbolic deductions tasks. Among those constructs are symbolic number sets ...
23
votes
1
answer
531
views
What's the difference between these 2 associations?
I have 2 associations similar to these simplified ones:
...
0
votes
0
answers
43
views
The command Total sums the entries of a list, is there a comparable command for the product of entries of a list? [duplicate]
I recently just found out about the command Total that gives the sum of a list. Was wondering whether there's an analogue that gives the product of the entries of a list? I see that there is the ...
6
votes
1
answer
150
views
Why Does Subsets[...,{n}] not Output a Packed List, Even Though it Doesn't Unpack?
Assume list is packed.
I expect Subsets[] is a structural operation because it depends on the number of elements, not on what ...
3
votes
1
answer
86
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 ...
6
votes
3
answers
531
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
...
1
vote
0
answers
89
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 ...
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 ...
7
votes
1
answer
106
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 ...
1
vote
2
answers
156
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 ...
6
votes
2
answers
307
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
1
answer
195
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
0
answers
64
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
1
answer
178
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 ...
11
votes
1
answer
233
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 <...
5
votes
1
answer
651
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 ...
14
votes
0
answers
133
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 ...
12
votes
2
answers
283
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 ...
7
votes
3
answers
491
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
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"...
5
votes
1
answer
432
views
What is the point of StringForm?
I never really understood the point of StringForm returning a StringForm rather than a String...
15
votes
2
answers
358
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 ...
11
votes
2
answers
478
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:
...
12
votes
2
answers
267
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:
...
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 <...
5
votes
0
answers
230
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 ...
27
votes
2
answers
641
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 ...
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 ...
32
votes
3
answers
2k
views
Resolving my Entity* Crisis
In the Wolfram Language I can usually guess a function's name, operation or idiomatic application but I don't have such a sense for various Entities ...
... instead, I seem to keep needing to consult ...
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}
...
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 ...
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 ...
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 ...
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:
...
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:
...