0
$\begingroup$

Suppose that I have a list, allSpecies, that contain a set of symbols, each of which has been assigned a new notation using Notation[...]. As an example, the internal representation is C60s, and the display form is C60* (but with the * back against the C -- not sure how to do that on StackExchange).

I now want to define a new Notation for single-parameter functions of any of the symbols that are in allSpecies. So C60* [t] (for any t) could be entered as and would be displayed as [C60*]t. Critically, I only want this alternate functional notation if the symbol is in allSpecies.

I have tried to accomplish this following the model shown here. So I defined:

StringMemberQ[any___]:=MemberQ[ToExpression[any]

And I then used the Notation palette to add a Notation entry. The left-hand side became [stuff1]t_ and the right-hand side became stuff2[t_], where the two "stuff" parts I began with InsertPatternWrapper from the palette, and Stuff1 was a_/;StringMemberQ[a,allSpecies], and Stuff2 was a_/;MemberQ[a,allSpecies]. But it doesn't work. Here is the expanded version of the code:

Notation[ParsedBoxWrapper[
SubscriptBox[
RowBox[{"[", TemplateBox[{RowBox[{"a_", "/;", 
RowBox[{"StringMemberQ", "[", 
RowBox[{"a", ",", "allSpecies"}], "]"}]}]}, 
"NotationPatternTag"], "]"}], "t_"]] 
\[DoubleLongLeftRightArrow] 
ParsedBoxWrapper[
RowBox[{
TemplateBox[{
RowBox[{"a_", "/;", 
RowBox[{"MemberQ", "[", 
RowBox[{"a", ",", "allSpecies"}], "]"}]}]}, 
"NotationPatternTag"], "[", "t_", "]"}]]]

Any suggestions are greatly appreciated!

$\endgroup$
0
$\begingroup$

Found a way to make it work.

MakeSpecies[f_] := With[{n = ToString[f,StandardForm]}, 
     Notation[ParsedBoxWrapper@SubscriptBox[RowBox[{"[", n, "]"}], "t_"]
     \[DoubleLongLeftRightArrow]
     ParsedBoxWrapper@RowBox[{n, "[", "t_", "]"}]]]

And then I just call it for each of the species that I want to behave this way.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.