Re: operator definition
- To: mathgroup at smc.vnet.net
- Subject: [mg84769] Re: operator definition
- From: "Steve Luttrell" <steve at _removemefirst_luttrell.org.uk>
- Date: Sun, 13 Jan 2008 05:48:15 -0500 (EST)
- References: <fm7ddq$elg$1@smc.vnet.net>
You can do this with the notation package.
In version 6 this is as follows:
In[1]:= <<Notation`
Define the notation.
In[2]:= <I have copied this as a Cell Expression immediately below,
otherwise it loses some essential information>
Cell[BoxData[
RowBox[{"Notation", "[",
RowBox[{
TagBox[
RowBox[{"u_", " ",
UnderscriptBox["<", "i_"], " ", "v_"}],
"NotationTemplateTag"], " ", "\[DoubleLongLeftRightArrow]", " ",
TagBox[
RowBox[{
"u_", " ", "\[Intersection]", " ", "v_", " ", "\[Intersection]",
" ",
RowBox[{"{", "i_", "}"}]}],
"NotationTemplateTag"]}], "]"}]], "Input"]
Check that the notation parses to the correct internal form.
In[3]:= firstset \!\(\*UnderscriptBox["<", "i"]\)secondset//FullForm
Out[3]//FullForm= Intersection[firstset,secondset,List[i]]
Run through an example.
In[4]:= firstset=RandomInteger[{1,10},10]
Out[4]= {9,8,2,1,7,3,4,8,7,10}
In[5]:= secondset=RandomInteger[{1,10},10]
Out[5]= {9,10,2,7,4,8,4,10,9,3}
In[6]:= i=Apply[Sequence,RandomInteger[{1,10},10]]
Out[6]= Sequence[7,5,5,7,6,9,8,10,9,7]
In[7]:= firstset \!\(\*UnderscriptBox["<", "i"]\)secondset
Out[7]= {7,8,9,10}
Stephen Luttrell
West Malvern, UK
"P_ter" <peter_van_summeren at yahoo.co.uk> wrote in message
news:fm7ddq$elg$1 at smc.vnet.net...
> Hello,
>
> I want to define an operator like(note the "i_" under the "<". As an
> example:
> firstSet_ \!\(\*UnderscriptBox["<", "i_"]\) secondSet_ :=
> firstSet \[Intersection] secondSet \[Intersection] {i}
>
> But Mathematica refuses to accept this. It says:
> Syntax::sntxi: Incomplete expression; more input is needed.
> What could I do better?
> with friendly greetings,
> P_ter
>