In the Mathematica front-end, symbols that have been defined are colored black and symbols with no definition associated are colored blue. This is useful to prevent spelling mistakes. Also, defined symbols appear in the autocomplete (as of Mathematica v9.0).
I have a symbol chrom
with no definitions associated, but I want Mathematica to recognize it. That is, I want that when I type chrom
in the front end, it appears colored black, and I want it to appear in the autocomplete.
I can't associate a definition with chrom
(as in chrom = ...
or chrom[..] = ..
, because then if chrom
appears in the evaluation of an expression, it will be replaced by the associated defined value. This is not the behavior I want.
In other words, is there a Mathematica function that does the opposite of Remove
? Remove
removes a symbol from the symbol table. How can I add a symbol to the symbol table without associating a definition with it?
chrom = Unevaluated[chrom]
now it is not blue anymore next time it is typed. and no value is associated with it either. $\endgroup$n=n
will also work. So now you have 2 ways to do it. I am sure where are more. Pick the one you like :) $\endgroup$n=n
is trick to forcen
to be added to the symbol table. Just liken=3
adds it to the symbol table $\endgroup$chrom = chrom
has been evaluated,chrom
is in the symbol table, pointing to itself. That's OK. After that I evaluatechrom
. Since at this pointchrom
is pointing to itself, why it isn't replaced withchrom
, which in turn is replaced withchrom
, and so on? $\endgroup$chrome
defined when you dochrom = Unevaluated[chrom]
! You just have to look at the return value when you evaluate the line, becauseSet
returns what has been assigned. If you still need further proof then checkOwnValues[chrom]
. Same argument is true forchrom=chrom
btw. $\endgroup$