# Tag Info

10

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] ...

9

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 ...

7

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

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

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 ...

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 ...

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" ...

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

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

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_, ...

3

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 ...

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 -> ...

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

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