Skip to main content

All Questions

Filter by
Sorted by
Tagged with
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 ...
Jonah's user avatar
  • 121
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 ...
cybervigilante's user avatar
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 ...
Alan's user avatar
  • 13.8k
4 votes
1 answer
332 views

Differences between minimization functions?

There's more than 20 functions having to do with minimization ...
Adam's user avatar
  • 4,006
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 ...
Syed's user avatar
  • 59.4k
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 ...
Gravifer's user avatar
  • 904
23 votes
1 answer
531 views

What's the difference between these 2 associations?

I have 2 associations similar to these simplified ones: ...
Coolwater's user avatar
  • 20.5k
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 ...
Paul B. Slater's user avatar
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 ...
Just Some Old Man's user avatar
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 ...
Rene Duchamp's user avatar
  • 1,419
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 ...
ynn's user avatar
  • 243
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 ...
Jerry's user avatar
  • 2,469
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
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 ...
Alexey Popkov's user avatar
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 ...
Display Name's user avatar
  • 2,059
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 ...
Alan's user avatar
  • 13.8k
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 ...
user5601's user avatar
  • 3,790
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 ...
Alexey Popkov's user avatar
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 ...
Dimitris's user avatar
  • 4,884
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 <...
bcp's user avatar
  • 791
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 ...
wangtwo's user avatar
  • 151
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 ...
Mr.Wizard's user avatar
  • 273k
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 ...
Artem's user avatar
  • 1,037
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 ...
Alan's user avatar
  • 13.8k
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,814
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...
Alan's user avatar
  • 13.8k
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 ...
Alexey Popkov's user avatar
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: ...
Vladimir Reshetnikov's user avatar
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: ...
masterxilo's user avatar
  • 5,779
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
  • 273k
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 ...
ELLIOTTCABLE's user avatar
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 ...
Szabolcs's user avatar
  • 236k
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
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 ...
Ronald Monson's user avatar
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
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
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
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
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