# Tag Info

51

May be this, I have not tried it, but it sounds like this is what you are looking for (if I understood you correctly): Evaluation menu -> Notebook's Default Context -> Unique to This Notebook. So, you do the above for each notebook. I found this in the daily Mathematica tip webpage: http://twitter.com/mathematicatip Update If you want to do it ...

42

Yes, there is. I recommend reading documentation related to Mathematica contexts. In a nutshell, all variables belong to some context (namespace), and all variables can be accessed via their fully-qualified names of the form "ContextNamevarName". If you just use "varName", Mathematica will search contexts in $ContextPath (try evaluating the variable ... 29 Symbols are created in the current context during parsing. This should not be a problem in normal circumstances as the symbols are merely "initialized" without values or properties. See these posts for more information: Is it possible to use Begin and End inside a Manipulate? Why doesn't this use of Begin[] work? When does Mathematica create a new ... 29 An ugly hack, look at all things in Global context, keep in table if Dimensions didn't return {} Grid[Select[{#, Dimensions[ToExpression@#]} & /@ Names["Global*"], #[[2]] != {} &], Alignment -> Left] For this to be helpful it needs to be updated dynamically and preferably be in a palette to avoid scrolling up all the time. Instead of ... 25 Some observations on Removed Removed is not a normal head, but rather a print form. Consider a definition x := y Once we Remove the y, we invalidate x in a subtle but permanent way - reintroducing the y into the session won't help. Remove is really a rather special-purpose destructuve operation, aimed more at removing auto-generated symbols. In a system ... 25 Maybe this ? ClearAll["Global*"] 20 Unique will do precisely this. Try for example Unique[x], which returns a symbol with a name similar to x$123. Here I should mention the Temporary attribute as well, which, when associated with a symbol, causes that symbol to be removed from the system when it's no longer referenced. This is occasionally useful when you need Unique. But whenever you do ...

20

One solution is to use the third argument of ToExpression: With minimal modification, a working version of your code would look like this: Table[ ToExpression[ mmsignalnames[[i]], InputForm, Function[name, name = Extract[ToExpression[celfilenames[[i]]], mmammindices[[j]]], HoldAll]], {i, Length[mmsignalnames]}, {j, ...

20

In the days when computers were slower, and the kernel took a long time to start up (in wall time), a little package was made to help with cleaning up without having to restart the kernel. This package is still included with Mathematica, and is found in AddOns\ExtraPackages\Utilities\CleanSlate.m (within the Mathematica installation directory). It is more ...

20

An alternative that doesn't require protecting or using private contexts: Clear @@ DeleteCases[Names@"*", "b"];

19

I usually use ToExpression["symbol", InputForm, ValueQ] ToExpression will wrap the result in its 3rd argument before evaluating it. Generally, all functions that extract parts (Extract, Level, etc.) have such an argument. This is useful when extracting parts of held expressions. ToExpression acts on strings or boxes, but both the problem with ...

19

Max[StringLength@Names["System*"]] 38 Select[ Names["System*"], 38 == StringLength[#] &] {"MultivariateHypergeometricDistribution"} As far as I can say there is no limit for lengths of symbol names, besides that of the memory limitation.

18

The only reliable way seems to have a good set of unit test suites, and run them in earlier versions of Mathematica (I mention this here since the answer and comments mentioning this were deleted). However, having explicit rules for when functions were introduced and / or last changed, extracted from the docs, seems to me a good thing, which may help reduce ...

17

Shorthand notations: All those shorthand notations are well documented. For double struck letters like $\mathbb{A}$, use EscdsA, where ds stands for "double struck" For script letters like $\mathcal{A}$, use EscscAEsc, where sc stands for — you guessed it — "script". Creating your own aliases: To create your own aliases, use InputAliases. I use it to ...

17

The short answer is don't do it. Really, it's just not a good idea. You can use other symbols, such as \[CapitalIota] which looks almost exactly like I and is entered with EscIEsc. If you're really determined you could substitute symbols using $PreRead and MakeBoxes but again I don't recommend it. For example: MakeBoxes[I, _] := "\[ImaginaryJ]" ... 17 This behaviour has changed since that book was published. I am writing this additional answer to make it clear how Mathematica 9 searches contexts for symbols and that even the current version 9 documentation is incorrect in describing this. How symbol lookup actually works When you enter a symbol name such as x, Mathematica will check if a symbol with ... 17 The answer is quite simple. Most people want to multiply numbers without having to use the * symbol, e.g. 3x vs 3*x. So given that this exists in Mathematica, using () for function arguments would introduce ambiguity. Is f(x + y) meant to be f[x + y] or f*(x + y)? This is actually a problem Wolfram|Alpha can face since we try to allow for all forms of ... 15 I found the solution. Mathematica is set up to use the font KLIpIqaDmey. The tip-off is in the UnicodeFontMapping.tr file referenced in the question. The header reads: @@resource UnicodeFontMapping Mathematica: Times Automatic Mathematica: (Times Courier) Automatic Mathematica: (Mathematica1 Mathematica1Mono) Automatic Mathematica: (Mathematica2 ... 15 How about this: list = {1, 2, 3}; ToExpression["list", InputForm, Hold] /. Hold[v_] :> AppendTo[v, 3] {1, 2, 3, 3} list {1, 2, 3, 3} 14 Not to detract from the existing answers (particularly @WReach's suggestion, which was the same solution that came to my mind as I read your question, and which I will use here), but you may find it easier to define your own references rather than using strings. (In fact, I wouldn't necessarily recommend an approach based on building Mathematica expressions ... 14 I use a shortcut key Ctrl+Q for Quit[], allowing rapid clearing of all sessions variables. Here is how you can add this to Mathematica: You will be editing KeyEventTranslations.tr. This is an important system file so be careful. Start by copying the file you are going to edit from the$InstallationDirectory to $UserBaseDirectory in the same tree. This ... 14 If you look at the generated code (CompilePrint, for example), the procedure is as follows: All the program's constants are placed into separate registers (regardless of their location in the program, they can be in the r.h.s.of variable initialization in scoping constructs, or they can be statements in their bodies. Actually, same constants found in ... 14 The definitions aren't being lost, they're being shadowed, as described in the tutorial on contexts. Mathematica doesn't warn you about this because it only warns when there is shadowing between contexts that are listed in the$ContextPath. Since Begin only changes $Context and not$ContextPath, you don't get a warning when the symbol that causes shadowing ...

13

There is a special-purpose function for this, Unique: In[270]:= Unique[] Out[270]= $3 In[271]:= Unique[a] Out[271]= a$4318 However, these symbols will be guaranteed to be unique only within a given Mathematica session.

13

You are missing Unevaluated: SetAttributes[f, HoldFirst] f[x_] := {SymbolName[Unevaluated@x], x} because SymbolName does not hold its arguments, so you have to prevent evaluation also there. Generally, if you are passing some argument via a chain of function calls, and want to keep it unevaluated, you have to prevent it's evaluation at each stage ...

13

Below is something posted on Mathgroup by Jason McKenzie Alexander. I made a few tiny changes and corresponded about this with Jason for a short while. He sent me his final version, which I post here with his permission. The original (linked above) is really only a few lines of code and can be studied to grasp the principle. The code below is a full package. ...

13

You can use String "keys" for indexed variables, as I did for A combination of Set::setraw and Set::shape errors. The strings can have spaces or any other characters you want to use: var["Degree of the First Polynomial"] = (* stuff *); You also have a wide range of characters, many of which can be used in Symbol names. Go to menu Palettes > Special ...

13

You can use any built in operator modified with subscripts, superscripts, etc, and retain its precedence, for your own purposes. For example, say you want a general Apply operator like @@ that could work at any level. One could use create the operator @@ with a number subscripted for the level of Apply seems appropriate MakeExpression[RowBox[{fun_, ...

13

It appears since version 3 shadowed variables are given priority, as demonstrated below. In the temp context x is taken as tempx unless Globalx exists. Remove[tempx, Globalx] tempx = 6; Begin["temp"]; {x, Globalx} End[]; {6, x} Remove[tempx, Globalx] tempx = 6; x = 5; Begin["temp"]; {x, Global`x} End[]; {5, 5}

12

The guide Listing of Named Characters in Mma docs: Mathematica provides systemwide support for a large number of special characters. Each character has a name and a number of shortcut aliases. They are fully supported by the standard Mathematica fonts. For further information about named characters, including character interpretations and naming ...

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