Hot answers tagged

27

Executing Trace on an expression reveals what is actually happening: Trace[Remove@x; x = 1] (*{Remove[Removed[x]];Removed[x]=1,{Remove[Removed[x]],Null},{Removed[x]=1,1},1}*) "the Wolfram Language always reads in a complete input expression, and interprets the names in it, before it executes any part of the expression." (see: https://reference.wolfram.com/...


27

Thanks to the hint by Jason. It is called AutoMultiplicationSymbol. It can be turned off in the Option Inspector: It worked. Now × does not show up. Version 11.1 on windows 7.


20

You can use ToExpression. Paste your content inside quotes and select "yes", in order to escape backslashes and use them verbatim: ToExpression["string", TeXForm, HoldForm]


18

You can use SyntaxInformation: SyntaxInformation /@ {Sin, Replace} // Column


16

Perhaps something like this?: DynamicModule[{key = ""}, EventHandler[ Dynamic[key], {"KeyDown" :> (key = CurrentValue["EventKey"])} ]]


12

You can add an input alias to do this. For example: CurrentValue[EvaluationNotebook[], {InputAliases, "mf"}] = TemplateBox[ {"\[SelectionPlaceholder]","\[Placeholder]","\[Placeholder]"}, "MixedFraction", DisplayFunction->(RowBox[{#1, FractionBox[#2,#3]}]&), InterpretationFunction->(RowBox[{#1,"+", FractionBox[#2,#3]}]&) ]; ...


10

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 clarify this as I have not seen this terminology used elsewhere (and WRI may not agree this is a useful concept). The "Theory" First let's consider what ...


10

On Windows, MathKernel.exe launches the kernel running within a window. The standard output is redirected to that window. To avoid this redirection, we must run the kernel as a console application using Math.exe instead: "C:\Program Files\Wolfram Research\Mathematica\10.0\Math" ^ -noprompt ^ -script C:\Users\a\Desktop\test.m ^ "data goes here" ...


10

Iconize is not meant to be used this way. Do not assign the result to a variable. Above, you are assigning the output to a variable, i.e. storing it in kernel memory. The purpose of Iconize is to be able to store expressions in a notebook without having them take up a lot of visual space. The icon can be copied around within the notebook, and inserted ...


9

The following solution seems to work reasonably well, at least on a few examples I have tested. It will be in the spirit of the one I gave to a rather similar earlier question you asked. I wasn't able to make the Tab key work, instead I bound the indenting to the CTRL+ ` combination - but in practice this is almost as easy as pressing Tab key. Also, the ...


9

Here is some Mathematica code as it appears after writing it my text editor. In a Mathematica note book I create a new Code cell with Cmd+8 (in OS X), and paste the code from the text editor into the cell. The gray background indicates the cell has the initialization cell property. Don't want that. With the mouse cursor in the Code cell (or with the cell ...


9

The subscript is interpreted as Times[Subscript[H, 2], O], and Mathematica uses spaces to denote multiplication. You can work around this by using the ZeroWidthTimes option:


6

First of all, consider the following two successive inputs: Remove[f]; f[x_] := 1; {f, Head[f], SymbolName[f], AtomQ[f], DownValues[f]} {f, Head[f], SymbolName[f], AtomQ[f], DownValues[f]} {Removed["f"], Symbol, "f", True, {HoldPattern[Removed["f"][x_]] :> 1}} {f, Symbol, "f", True, {}} From the outputs it becomes clear how the things work: 1) All ...


6

When we open a new notebook in the front end, we get that gray line with the plus sign in the upper left corner, as you show. We click the plus sign and get the drop-down menu, as you show. Now we have some options. Wolfram Language Input -- this first option on the drop-down just opens an input cell for use. We don't need to open the drop-down, though, ...


6

This happens because the expression For is complete at the location of the newline. Mathematica will not attempt to read further. Instead, it will try to interpret the next line as the start of a new expression. Compare this with For[ which is incomplete at the newline. Mathematica will read further to try to complete it. Thus, use For[ i=1, i<4,...


5

Checking that a file is in use by another application is very operating system dependent. As far as I know, Mahtematica doesn't support testing for this in user code. Reading in a file that is in use by another app is harmless in itself. OpenWrite can be dangerous because it always deletes any pre-existing file before proceeding. So perhaps you should ...


5

My approach is to use the Option Inspector (menu command Format > OptionInspector) to set the option for the relevant cells UnderscriptBoxOptions -> {LimitsPositioning -> False} If I'm doing this a lot, I might create a new style that inherits from "Text", or change "Text" itself (e.g., via a private stylesheet). Or one can create a template of ...


5

Here is a much more modest try for blocks of code. :) You could expand it to cover text like @LeonidShifrin has shown. It could also be reversed to unindent. SetOptions[$FrontEnd, FrontEndEventActions -> { {"KeyDown", "\t"} :> NotebookWrite[ InputNotebook[], Insert[ NotebookRead[InputNotebook[]] /. "\[IndentingNewLine]" -&...


5

The theory you propose in your comment to the question puts you on the right path. But there is a little more to it than that. In an input mode (and there is more than one) when you type in an asterisk it is interpreted as Times and is rendered by a special glyph, unicode 22C6 (unicode name: STAR OPERATOR) In a text mode (again, there are more than one). ...


5

So, a large part of this question seems to be concerned with whether or not BinaryReadList can cause meaningful damage to an underlying drive (SSD or HDD). From what I can see, the answer to this should generally be no, regardless of internal implementations. Regarding SSDs: this Super User answer seems to state that reads on SSDs are essentially free. No ...


5

Ctrl+Shift+Enter is the keyboard shortcut for "evaluate in place", which you press after highlighting an expression; this should ease your task. – J. M.♦ 2 mins ago Notice I used Defer, it holds its arguments and is stripped when boxes are created. Exactly what we need keep e.g. 1 + 1 in this form. Related: How can I change mouse hover behavior for ...


5

Try wrapping the Option value in Dynamic: Panel[Column[{InputField[Dynamic[purchaseprice], Number, FieldHint -> "Purchase Price"], InputField[Dynamic[EK], Number, FieldHint -> "Equity capital"], InputField[Dynamic[mortgagerate], Number, FieldHint -> "Mortgage Rate in %"], InputField[Dynamic[supplymentary], Number, FieldHint -&...


5

This might be a bug. However, I think linear syntax is evil, and would recommend that you avoid it like the plague. Instead, just use an expression: Plot[x^2, {x, -3, 3}, PlotLabels -> x^2] Addendum Question: What is linear syntax? Answer: It is something like "!(x\^2)". This is what happens to a string when you perform 2D formatting inside of a ...


5

With an input auto replacement like "fss", you need to have some way of telling Mathematica that "fss" is a complete token. That is, "fss" only gets replaced when the next character is not a letter. The usual input auto replacements typically get replaced when you type a letter, e.g., a->b only becomes $a\to b$ after you type the letter "b". So, to make ...


5

Here's something you can try: CurrentValue[EvaluationNotebook[], {InputAliases,"ch"}] = ActionMenuBox[ "g1", { "g1":>NotebookWrite[EvaluationBox[], "g1"], "g2":>NotebookWrite[EvaluationBox[], "g2"] }, Appearance->"PopupMenu", AutoAction->True ] A short animation: The left hand side of the rule is what you see in the ...


5

The percent symbol % in Mathematica represents the last output Out[-1], see the Documentation for Out. Hence the results you observe. In principle you can use Inline Free-form Input for this: press Ctrl+= and type your 50%, then press →, * and Ctrl+= again and type your next percent quantity 80%, and so on: Then press Shift+Enter to perform the computation:...


4

This problem is typical for all keyboard layouts where = is typed in by using Shift, for example, as Shift+0 on a German keyboard. On such a keyboard Ctrl+= is typed in using Ctrl+Shift+0. However, under Windows Ctrl+Shift by default is the keyboard shortcut used to switch between input languages. The following screen snipped shows how to deactivate this ...


4

The keyboard shortcut might be different on your computer if you use a non-English keyboard layout. Or at least it's worth checking this. Go to the Insert menu and look for "Inline free-form input". It's the fourth entry in the menu. The keyboard shortcut will be shown next to it.


4

Just press F2 (I cant accept my own answer as an answer now as a new user)


4

To change your cell label styles at a notebook level, go to Format > Edit Stylesheet. Then in your stylesheet enter exactly CellLabel in the 'Enter a style name' input field. This will then allow you to apply all the usual formatting options to cell labels. Alternatively, you can use the Option Inspector. Open the Option Inspector and change the first ...


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