Questions on correct (or improved) formulation of Mathematica code to achieve particular results. Use this tag (not "symbol") for questions about all those odd @@ /@ # & and ~ characters.

learn more… | top users | synonyms

43
votes
2answers
1k views

Head and everything except Head?

I have been working on picking expressions apart using Head and Part and encountered a little mystery. Consider the canonical ...
10
votes
3answers
338 views

Why does ++++x return an increment of 2 when the value of x is only incremented by 1?

This line returns 3: x = 1; ++++x However, the value of x after the increment is only ...
4
votes
3answers
319 views

Brackets in output make unable to use output to identify matrix element

I'm trying to write a code where each matrix element swaps with a randomly selected neighbor (cardinal directions only) to redistribute the matrix. So far I've been able to replace an element with its ...
10
votes
3answers
939 views

Working with PhysicalConstants

I recently found the PhysicalConstants` package. First I thought this was nice, since I didn't have to look up some quantities all the time and copy them into the ...
1
vote
1answer
158 views

Differentiation w/o assiging concrete values

v = Subscript[v, 0]*Sin[(Pi*S)/Subscript[S, 0]]; a = dv/ds v; a = D[v, s] returns ...
24
votes
1answer
473 views

Why doesn't PatternTest work with Composition?

While playing around with the solutions to this question, I've found some very strange behaviour: ...
28
votes
4answers
13k views

Is there a syntax for single-line comments for notebooks?

I'm aware that I can use (* ... *) to comment out stuff in a notebook. Many languages have a syntax for single-line comments, such as ...
3
votes
2answers
726 views

Single dot textual form

How do I render a letter with a single dot above it? I see \[DoubleDot] and \[TripleDot] are readily available, but what about ...
3
votes
5answers
619 views

Using variables in function names

I want to make a list of plots and my functions are named C1, C2... Cn. The command I wish ...
5
votes
4answers
306 views

Multiple colors in Graphics[] environment

There are other questions on the site that are similar to this one, but the answers provided didn't help me. I want to draw disks of different radii. Each radius is the absolute value of a variable, ...
13
votes
2answers
1k views

Representing second derivatives with a double overdot

I would like to express a second derivative with two dots above the variable. You can do this with a first derivative by saying: ...
9
votes
2answers
920 views

Flatten at a certain level

In an earlier question the brainteasing fourth syntax variant of Flatten was discussed. I see that with ...
20
votes
5answers
888 views

How do you programatically load data into symbols?

I am trying to convert a list of string names into symbols, which will then be used to store data. I have 24 files (where the name of each file is a member of the list mentioned above) that I need to ...
12
votes
3answers
450 views

With versus Function

I've seen people compare Block with Module and With as scoping constructs, and try to figure ...
50
votes
7answers
2k views

Functions vs. patterns

Every time I define a new function, I wonder which construct I should use: true functions obtained by using Function, or rule-based syntax. For example, these are ...
15
votes
2answers
442 views

Distributing PlusMinus consistently

I would like to give the built-in function PlusMinus, which is undefined by default, the intuitive meaning: considering all possible combinations of $+$ and $-$. ...
7
votes
2answers
303 views

What's the purpose of the Unique function?

As the title says: What's the purpose of Unique? I understand that it generates some unique symbol, but when and for what is it to be used? Are there applications ...
25
votes
5answers
3k views

Clear complains that a subscripted variable is not a symbol or a string?

Here's a small listing where I've used EscqEsc to typeset θ in the notebook: ...
26
votes
1answer
665 views

Convenient string manipulation

With Mathematica I always feel that strings are "second class citizens." Compared to a language such as PERL one must juggle a lot of code to accomplish the same task. The available functionality is ...
18
votes
5answers
603 views

Change syntax from other programs to mathematica syntax

Is there a good way to transform syntax from other computer algebra systems or from latex to mathematica syntax?
63
votes
2answers
2k views

Flatten command: matrix as second argument

One thing I could never wrap my head around is how Flatten works when provided with a matrix as the second argument, and the Mathematica help isn't particularly ...
31
votes
4answers
716 views

Usage of \[InvisibleApplication] and other related invisible characters

From the front end, \[InvisibleApplication] can be entered as Esc @ Esc, and is an invisible operator for @!. By an unfortunate ...