# Tag Info

13

Currying I don't know if it is possible to make all functions work in the Currying form (h[x1][x2][..]) but it is at least possible to extend Hold behavior to all arguments which natively that pattern will not have. I will copy my favorite method which was posted here by Grisha Kirilin: SetAttributes[f, HoldAllComplete] f[a_, b_, c_] := Hold[a, b, c] ...

13

You can get the syntax highlighting that you desire by modifying your UnicodeCharacters.tr file, though I don't know how advisable this practice is. For example, adding: 0x20B0 \[PennyOp] ($penny$) Infix 155 None 5 5 I can use EscpennyEsc to enter: I am not aware of documentation of the format of this file but as ...

8

Unlike arrays in many other languages, in many cases Mathematica allows you to deal with lists of data without the need for indexes at all. Lists can be of variable depth and lengths if you need them to be. cities = {"NewYork","LosAngeles","Chicago"}; costs = {{1,2}, {3,4},{5,6}}; Transpose[{cities, costs}] This gives you a list of cities and associated ...

8

You cannot simply type Symbolize[...] which you should probably know from an error message you should be getting. For example what you have in your question gives: Symbolize[Subscript[q, 1],Subscript[q, 2]] To see why you get this message you can use show expression to see what is being pasted via the palette: From this we can see that Symbolize ...

7

The possibility to insert operators and functions as you know them from mathematics is not possible for all things. Usually, you find the special input possibilities on the reference page of the function in the Details section. See for instance the documentation of Integrate. For Binomial there seems to be no such 2d input, because as you already found out, ...

7

What I usually suggest for such cases is to use custom environments, inside which you can change the rules of the game. Here is a lexical one for your case: ClearAll[withNCTimes]; SetAttributes[withNCTimes, HoldAll]; withNCTimes[code_] := Unevaluated[code] /. Times -> NonCommutativeMultiply so that withNCTimes[a*b*c] (* a**b**c *) and here is ...

7

Instead of using the Notation package, you can achieve the translation by doing the following: MakeExpression[RowBox[{x_, "⟗", y_}], StandardForm] := MakeExpression[ RowBox[{"FlatJoin", "[", x, ",", y, "]"}], StandardForm ] This takes care of the input translation. Now it's possible to enter expressions like 1 ⟗ (3 + 4 ⟗ 2) and have ...

7

That's how I finally defined haskell operators: rapply[x_] := x rapply[x_, y__] := x[rapply[y]] InfixNotation[ParsedBoxWrapper["|"], rapply] lapply[x_] := x lapply[x__, y_] := lapply[x][y] InfixNotation[ParsedBoxWrapper["\[SmallCircle]"], lapply] InfixNotation[ParsedBoxWrapper["\[CenterDot]"], Composition] Now $\circ$, $\dot{}{}$ and | act exactly like ...

6

What you are really looking for is InputAutoReplacements. If I understand your question correctly you are looking for a simple/quick way to input mildly complex strings of characters. In your example you want to find an easy way to input $\beta$. But there is no point in creating another symbol beta, since the 2 symbols are meant to always be "equivalent" ...

5

One of the problems of the Notation package is that it is rather heavy and opaque, while what it actually does is rather simple. I suggest a very light-weight substitute for your case: Clear[MakeExpression,makeExpression]; MakeExpression[expr_,form_]:= With[{result=makeExpression[expr,form]}, result /; Head[result]===HoldComplete ]; ...

5

You appear to be looking for the functionality of $PreRead:$PreRead = # /. "beta" -> "\[Beta]" &;

4

I won't say anything about the performance, since I think there are not enough information what exactly your data is. Furthermore, I won't say anything about the Notation Package because I don't think it's necessary. Could I somehow give the dataframe a custom head of DataFrame, preferably without breaking anything? Yes, I think that's and easy and ...

4

I would not think that either of the methods you mentioned is good enough. Notation package is more or less limited to the FrontEnd (although one can come up with some hacks to make it work also in packages), while overloading Set is generally a bad idea. Having in mind your particular application, something like this may work: ClearAll[makePoint]; ...

4

It doesn't recurse because you are using a definition of Notation (from the Notation` package) that is restricted to parsing: This means that you will have to explicitly ShiftReturn for the notation to take effect. Notice the following: You can achieve what you want using straightforward definitions instead: Clear@WW WW[a__, Verbatim[Alternatives][b_, ...

4

Without giving this much thought you might proceed as follows: naturalQ = IntegerQ[#] && Positive[#] &; You can then define: fn[n_?naturalQ] := 2*n; fn /@ {-1, 0, 1} {fn[-1], fn[0], 2} For the second problem you might make use of SubValues syntax: SetAttributes[nFun, HoldAll] nFun[p_, body_][arg_?naturalQ] := With[{p = arg}, body] ...

3

but it is not working The above does not describe the problem you are having. When you say not working, you need to explain how it is not working, and what you tried. I just downloaded it and I see no problem. Using V10.01, on windows. Downloaded it from http://library.wolfram.com/infocenter/MathSource/577/ Here are some examples ...

3

Using $$(a + b ) \^ c$$ where \^ is short form for SuperscriptBox within $$...$$, gives SuperscriptBox[RowBox[{"(", RowBox[{"a", "+", "b"}], ")"}], "c"] as pointed out by @jkuczm, you can then solve by using RowBox. So I tried to do for the cases it didn't work and for others, like $(\frac{a}{b})^c$ I played a bit with the pattern matching in ...

3

If your custom notation is identical to that of Power, I would do it the lazy way: MakeBoxes[ myPower[base_, exp_], form_ ] := TagBox[ MakeBoxes[ base^exp, form], myPower] ; myPower @@@ {{x, y}, {x + y, z}, {x y, z}, {myPower[x, y], z}, {f[x, y], z}} { xy, (x+y)z, (x y)z, (xy)z, f[x, y]z } % // InputForm {myPower[x, y], myPower[x + y, z], ...

3

"these will end up being more trouble than they are worth." - to my mind, this is a very accurate assessment of the situation. As far as syntax is concerned, you will face multiple obstacles, starting from package and front-end parser differences you outlined (which makes the use of e.g. Notation package in packages quite non-trivial if not problematic), ...

2

I would strongly recommend that you not follow this approach. It is not a good idea to modify built-ins, especially something as fundamental as Times as this could lead to unintended consequences elsewhere. Instead, I would suggest that you utilize one of the many infix operators without any pre-defined meaning. That said, you could do something like: ...

2

The Notation function is part of the Notation package. You need to load the package first, then you can use the Notation palette to simply paste the Notation template and fill the placeholders. If you cannot use the notation palette,for ex. because you are using a code editor like in WB, then you use the notation template with option Action -> ...

2

As a workaround you can wrap base of MyPower with additional RowBox: Notation[ ParsedBoxWrapper[SuperscriptBox[RowBox[{"A_", ""}],"B_"]] \[DoubleLongLeftArrow] ParsedBoxWrapper[RowBox[{"MyPower", "[", "A_", ",", "B_", "]"}]] ] It works with Plus, Times, nested MyPower and custom functions: MyPower[x, y] MyPower[x + y, z] MyPower[x y, z] ...

1

Notation[OverBar[x_] \[DoubleLongRightArrow] Mean[x_]] z=Range[10]; OverBar[z] (* 11/2 *) n.b.: You cannot just copy/paste the above, per my comment.

1

This seems to work Format[△[θ_], TraditionalForm] := HoldForm[△ θ]

1

Method #1 If you define each Subscript using TagSet(1)(2) the value will be associated with the Symbol, e.g. k: k /: Subscript[k, 1] = "val1"; k /: Subscript[k, 2] = "val2"; k /: Subscript[k, 3] = "val3"; You could then use definitions such as: kval[] := UpValues[k][[All, 2]] ksym[] := HoldForm @@@ UpValues[k][[All, 1]] These will always be up to ...

1

Although I don't like the Notation stuff very much, I regard the question as very nice, because it offers some insight into the evaluation process. When you bind UpValues to the symbol k and k has DownValues (because you want it to hold your list too), you have to make sure that k is not evaluated because otherwise the rule you gave as UpValues never kicks ...

1

RemoveSymbolize does not seem to respond to patterns. Unclear whether this is by design or a bug. In any case you can use ClearNotations to revert from symbol to subscript:

1

I'm not sure how useful this is in your redundancy-free setting or at all, but I assume you don't want the non-commutative multiplication to happen everywhere. When you wrap your special data-type like for instance this M[data] than another approach would be possible M /: Times[M[a_], M[b_]] := M[MyProduct[a, b]] and you get the special multiplication ...

1

Ignoring Leonid's arguments on whether OO is a good idea, or not, I would like to suggest something a bit different. Instead of using MakeExpression, set a DownValue on CenterDot directly: a_ \[CenterDot] b_ := a[b] a_ \[CenterDot]b_\[CenterDot]c__ := a[b]\[CenterDot]c where the second definition makes \[CenterDot] left associative allowing you to string ...

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