Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

# Tag Info

27

Superscript is not interpreted as Power: Presumably you are referring to what happens when you enter a power in superscript notation using the key combination Ctrl+6. Mathematica is capable of representing both this power notation and a formatted plain Superscript. In my opinion it is a failing that the power notation appears in the Typesetting menu while ...

21

This syntax was deprecated in the version 6.0 era. According to the legacy documentation, For example, in version 5.2, the following strings are interpreted differently string1 = "first line second line" string2 = "\<first line second line\>"

14

I believe this is the documentation you are looking for: String Representation of Boxes Notably: And:

14

As djp explains parentheses are unnecessary in the FullForm of an expression; it is logical for superfluous information to be removed. However if you want parentheses to persist you could use something like this: $PreRead = # /. RowBox[{"(", body___, ")"}] :> RowBox[{"paren", "[", body, "]"}] &; MakeBoxes[paren[body___], form_] := MakeBoxes[{... 13 To enter the string in without double backslash, you could use a TextCell as follows: ToString@@Ctrl-9\abc\def\ghiCtrl-0 \abc\def\ghi FullForm[%] "\\abc\\def\\ghi" On the first line, I open a text cell and enter the text as you wanted to type it. The ToString knows how to convert the text cell to a string, as is shown in the last FullForm output.... 11 I would have expected this to either be the same as (a // f) /.a ->1, or as applying the replacement rule first and then the function (a /.a->1)//f It is neither of those. It is a precedence issue. It is interpreted as a // (f /. a -> 1) You can look it up, or you can check it like this: PrecedenceForm@HoldForm[a // f /. a -> 1] (* (f /. a ... 10 For internal representation, I prefer avoiding subscripts and superscripts, so I'll give a way for using superscripts for input and output formatting, while the internal expression is of the form x[i]. For output formatting, something like this: Format[x[i_]] := Superscript[x, i] Example Table[x[i], {i, 3}] For input, this works, but I would wonder ... 10 If I understand correctly, the closest to Python's triple quotes is a TextCell. You can enter it as follows: Here I opened an inline cell after typing the input a =. This is done by pressing Ctrl-9 (or going to the Insert menu, then to Typesetting... and Start Inline Cell). In the light orange highlighted box, you can type any text you want in a natural ... 10 Thanks to andre's comment (where this link is provided), I now see the effect of those delimiters (I tested it in Mathematica 11 and also some earlier versions). When I add 2 newlines to the box representation of the cell: Cell[BoxData["\"\<a bc\>\""], "Input", CellChangeTimes->{{3.662918813714031*^9, 3.6629188530623317*^9}}] and switch back ... 10 Summary of the all available information In the hoarier days space-like characters (spaces, newlines, tabs) inside strings were interpreted on input in an odd way: for example single newlines followed by spaces or tabs were converted to a single space. The \<\> syntax was introduced as a way to avoid this: between \< and \> the space-like ... 9 You can get your equation in unevaluated form using ToExpression["\\int_0^\\infty E^{-x^2}\\,dx = \\frac{\\sqrt\\pi}2", TeXForm, HoldForm] which wraps the expression in HoldForm before evaluation. Note the thin space before dx, which is needed for Mathematica to properly interpret the integral syntax, and the capital E. ToExpression["{HoldForm}[\\int_0^\\... 9 We can implement a raw string syntax using the global variable$PreRead, which "is applied to the text or box form of every input expression before it is fed to the Wolfram Language." Using $PreRead, we can get at the string before any interpretation has been performed on it, replace it with the corresponding InputForm expression, and send that along as ... 8 You can make them an expression if you want. Let par[x.....] represent (x....). For example: (x+y)*z The FullForm would be: Times[par[Plus[x,y]], z] But in every such expression, the par[..] would only ever have on argument (in the example, Plus[x,y]). It would never modify the meaning of the argument. So in FullForm, there would be no point having ... 8 These are Operator Input Forms Characters that are not letters, letter‐like forms, or structural elements are treated by the Wolfram Language as operators. The Wolfram Language has built‐in rules for interpreting all operators. The functions to which these operators correspond may or may not, however, have built‐in evaluation or other rules. ... ... 8 tl;dr In principle, yes. In practice, it's not worth the (considerable) trouble. In Mathematica, everything is an expression. That applies to both code and data. The standard textual representation of expressions is what InputForm returns and what we normally think of as the Wolfram language (Mathematica's programming language). But in principle you can ... 8 The number entry form base^^digits is only valid for explicit [0-9] digits in the place of both base and digits. You cannot write literal b^^1001 and then attempt to replace b as b^^1001 does not parse to this input form. Likewise the number entry form m*^exp is only valid for explicit [0-9] digits in the place of both m and exp. The combination of these ... 7 Turns out the answer is yes, simply use "PrintableASCII" character encoding rather than the FullForm/InputForm representation: str = "123\000456" ToCharacterCode[str] {49, 50, 51, 0, 52, 53, 54} I discovered this using: ToString[FromCharacterCode[{49, 50, 51, 0, 52, 53, 54}], InputForm, CharacterEncoding -> "PrintableASCII"] Which is basically ... 7 If you want to use superscripts so as to follow some textbook symbols then use Symbolize Needs["Notation"] I'm going to paste an image because pasting Symbolize gives you this: Symbolize[ParsedBoxWrapper[SuperscriptBox["y", "1"]]] 7 No. In fact, even$PreRead is ignored when reading .m files. What you can do is define a myGet as myGet[file_] := Module[{str}, str = Import[file,"Text"]; str = myTextReplacemeansts[str]; ToExpression[str]; ] to make your own substitutions.

7

Use Style with the option ShowStringCharacters -> False around the prompt: Row[{Style["Enter index identifier: ", ShowStringCharacters -> False], InputField[Dynamic[indexidentifier], String]}] After evaluating in place: Alternatively, you can use TextCell: Row[{TextCell["Enter index identifier: "], InputField[Dynamic[indexidentifier], String]}]

6

To input lists, use Ctrl+, which creates two place holders like so: You can move between them with Tab (forward) and Shift+Tab (backward), but not after you've entered a value. You can create a new column/element with Ctrl+, again and a new row with Ctrl+Enter. You can use this form anywhere you need a list/matrix: Documentation: Entering Tables and ...

6

Its a bit like pulling teeth, but here is a way to preserve keyed-in numbers as strings: \$PreRead = ReplaceAll[#, s_String /; StringMatchQ[s, NumberString] :> ((Characters @@ #) &@ HoldForm[s]) ] &; hisData = StringJoin /@ {0.05467, 12.34230, 4.69, 9.3452} myData = ...

6

The symbol is \[ContourIntegral].

6

Unfortunately, I don't think there is. The association between characters and symbol names is burned into the kernel (in the form of a "yacc" grammar), with complete information about associativity, precedence, and tokenization. Consider something as simple as your dot example. Presumably you want 2.3 to be the real number 2.3, not myDot[2,3]. How would ...

5

Works ok like this, without the cell change times. I didn't change anything else. Paste it into a notebook and choose 'interpret', or don't and prefix it with CellPrint to see the code. Cell[BoxData[RowBox[{RowBox[{"\[CapitalOmega]", SuperscriptBox[RowBox[{"(", RowBox[{"B\[Beta]", "|", "B\[Alpha]"}], ")"}], "B\[Beta]"]}], "=", ...

5

Edit: See here for a better answer. Just a slight modification of Mechanical snail's answer here, (I need a more creative username...) to make the output match the input exactly. In[1]:= {{2}, {3}} // MatrixForm In[2]:= ToExpression[InString[1], StandardForm, Defer] // DisplayForm Which you can copy/paste, or just append //CopyToClipboard to the command ...

5

I'm going to assume you want this specific char: Unicode Han Character The issue is not with Mathematica's character code conversion, but instead the encoding source. The value you have obtained is in Hex, where you need the decimal to use FromCharacterCode. Hex-> Dec-> Front end FromCharacterCode[Interpreter["HexInteger"]["5929"]] References 78666

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

Here is a possible implementation for explicitPrecision. explicitPrecision[x_String] := Module[{u = StringSplit[x, "."]}, If[Length[u] == 1, Return[{0, StringLength[u[[1]]]}]]; If[u[[1]] == "0", Return[{0, StringLength[u[[2]]]}]]; StringLength /@ u] explicitPrecision[".0547"] {0, 4} explicitPrecision["0.0547"] {0, 4} explicitPrecision["12....

4

This points out that Legended is typeset instead of being evaluated in the kernel evaluation time. The evidence is in that InputForm[p] still contains two Legendeds and the graphics only one. This is what you need: Show[ListPlot[Range[10], PlotLegends -> {"a"}, PlotStyle -> Red], ListPlot[Range[10] + 2, PlotLegends -> {"b"}, PlotStyle -> ...

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