Hot answers tagged

37 votes

How can I adaptively simplify a curved shape?

We can use the Ramer-Douglas-Peucker algorithm to reduce the number of points. This algorithm was originally devised for processing map data. ...
Szabolcs's user avatar
  • 233k
34 votes

Character to replace _ in symbol names?

This has been discussed on comp.soft-sys.math.mathematica. The gist is that there are lots of Unicode characters you could use, e.g. \[LetterSpace] or ...
Martin Ender's user avatar
  • 8,744
27 votes

Why does removing a function and defining it on the same line not work?

Executing Trace on an expression reveals what is actually happening: ...
dan7geo's user avatar
  • 1,390
26 votes

How to make Mathematica variables declarative instead of just-in-time?

You are looking for $NewSymbol which is run every time a new symbol is created. For example, let say you only want x, ...
rcollyer's user avatar
  • 33.9k
19 votes
Accepted

How can I obtain a complete list of the kinds of atomic expressions in the Wolfram Language using only the language itself?

You can use EntityValue to find out what symbols can be atomic: ...
Carl Woll's user avatar
  • 130k
16 votes
Accepted

When is a symbol a Symbol? Is there an easy Mathematica way to test if an object is a symbol sort of like a SymbolQ?

I'd probably use x_Symbol in a function argument to control evaluation. Otherwise, one might do the following (thanks to @Leonid for pointing out an oversight). If ...
Michael E2's user avatar
  • 234k
14 votes

Why did Mathematica choose brackets for function arguments over parentheses?

Although Chip's answer already suffices to address the question, I would like to quote here a relevant part of the dialog by Theo Gray and Jerry Glynn in their book Exploring Mathematics with ...
14 votes
Accepted

How to make Mathematica variables declarative instead of just-in-time?

Edit: method extended for multiple contexts and unlocking mehtod added. Let's protect whatever is a new symbol. In old answer I've manually excluded symbols matching ...
Kuba's user avatar
  • 136k
13 votes

Generating list of alphabet letters

Nowadays, one can use Alphabet[] along with Take[] or Part[] + ...
13 votes

Character to replace _ in symbol names?

The issue is that Mathematica interprets underscore as Blank and interprets my_variable as a ...
dionys's user avatar
  • 4,321
13 votes

How can I define symbols but not have them show up in the front end?

Core Function Here's a single function that does all this coloring stuff: ...
b3m2a1's user avatar
  • 46.6k
13 votes
Accepted

Why does args symbol exist in a fresh kernel?

It's a type of otherwise harmless bug that tends to come and go with versions. I would suggest to report it to Wolfram, but also not to worry about it. Notice that the symbols have no associated ...
Szabolcs's user avatar
  • 233k
13 votes

What does $ mean in an output?

This usually means you've exported a local symbol from the context in which it was localized. Consider: Module[{x}, x] (* x$24939 *) Your results may vary. The <...
John Doty's user avatar
  • 13.7k
12 votes

Bug: With[] pattern-variable renaming misses symbols within `Except`

I agree that this is a bug. However, I want to point out that this usage of Except does not seem to be allowed in older versions. In version 9.0: We don't get the ...
Szabolcs's user avatar
  • 233k
12 votes
Accepted

Defining a symbol e that represents plus-minus-one, so that e^2 == 1 and e^3 == e

A quick way is to use TagSet[] and TagSetDelayed[] to teach Power[] how to deal with your ...
J. M.'s eventual burnout's user avatar
12 votes

PlusMinus definition unexpectedly affects plotting

It appears that PlusMinus is the only wrapper that is not Protected: ...
Mr.Wizard's user avatar
  • 270k
12 votes

When is a symbol a Symbol? Is there an easy Mathematica way to test if an object is a symbol sort of like a SymbolQ?

How about: SymbolQ[_Symbol] = True SymbolQ[_] = False ?
John Doty's user avatar
  • 13.7k
12 votes
Accepted

Equivalent for \hookrightarrow, ↪

You can use an empty TemplateBox to create a new operator. For example: ...
Carl Woll's user avatar
  • 130k
11 votes

How can I adaptively simplify a curved shape?

Here is my attempt to use ParametricPlot for obtaining an adaptive approximation of the shape. It is based on the code of glyph to ...
Alexey Popkov's user avatar
11 votes

How can I adaptively simplify a curved shape?

Here I present a very simple angle-based polygon reduction algorithm as described in the chapter "A Simple Algorithm" of David Eberly's "Polyline Reduction". The only addition is ...
Alexey Popkov's user avatar
11 votes
Accepted

1 is not the SameQ as Null, but why might 1 be Equal to Null?

=== (SameQ) tests structural equality and is meant mainly for programming uses. Like nearly all functions named as ...
Szabolcs's user avatar
  • 233k
11 votes
Accepted

How to list all user-defined symbols?

User defined symbols/functions are in the Global` context: a = 1; b[x_] := a x^2; c[x_] := f[x]; Names["Global`*"] {"a", "...
corey979's user avatar
  • 23.7k
11 votes

How can I implement a listener variable in Mathematica?

As part of handling this for myself I wrote a package that does it. The idea was to mimic the *Var() classes in tkinter. I'll do ...
b3m2a1's user avatar
  • 46.6k
11 votes

Make symbols atomic, without losing their type

Perhaps what you want is symbolic tensors: http://reference.wolfram.com/language/tutorial/SymbolicTensors.html ...
Szabolcs's user avatar
  • 233k
11 votes
Accepted

Make symbols atomic, without losing their type

You could use my TensorSimplify package help with this. Install the paclet with: ...
Carl Woll's user avatar
  • 130k
11 votes

How to generate a horizontal histogram with words?

First of all, you don't need a Histogram, you need BarChart. Secondly, you need to massage the data slightly so each data point ...
MarcoB's user avatar
  • 65.8k
10 votes
Accepted

Why does removing a function and defining it on the same line not work?

I use the word internal symbol rather than just symbol, to make it easier to distinguish between the name of a symbol and the internal representation of the symbol inside the kernel. I felt I should ...
Jacob Akkerboom's user avatar
10 votes
Accepted

Check if symbol is in core language

You can look it up using WolframLanguageData, which has a list of all pre-defined symbols: ...
C. E.'s user avatar
  • 70k
10 votes
Accepted

Change nested list of symbols to nested list of numbers

symbols = {e4, {e200, {e1, {e11, e23}}}}; Map[FromDigits@StringDrop[SymbolName[#], 1] &, symbols, {-1}] {4, {200, {1, {11, 23}}}} ...
kglr's user avatar
  • 384k
10 votes
Accepted

Implement abstract algebraic structure

I decided it was worth giving another example of modern OOP in Mathematica. There will be a small amount of code, but almost all of it is boiler-plate. I use a package to handle most of the boiler ...
b3m2a1's user avatar
  • 46.6k

Only top scored, non community-wiki answers of a minimum length are eligible