MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: function arguments as subscripts


Hi Henrik

> In[16]:=
>    \!\(foo\_\(k_, l_\) = k l\)

The FullForm of this is:
Set[Subscript[foo,Pattern[k,Blank[]],Pattern[l,Blank[]]],kl]

(You can get this by wrapping the expression with
 FullForm[Hold[..]])

Now it's apparent that you should define an upvalue for foo rather
than a downvalue for Subscript. So in order to define it in a
package, just insert a ^ in front of  "=" or ":=" or  put   "foo /:" in front of
the definition:

\!\(foo\_\(k_, l_\) ^= kl\)
or
\!\(foo\  /: \ \ foo\_\(k_, l_\) = kl\)

You can then check the definition by issuing ??foo:

??foo

"Global`foo"             (* or whatever package you choose *)
Subscript[foo, k_, l_] ^= kl


You can then set the usage string of foo:
foo::usage = "xxx"

??foo

xxx
Subscript[foo, k_, l_] ^= kl


Yours sincerely
  Bruno


  • Prev by Date: Re: How can I do this?
  • Next by Date: Re: Can someone explain this?
  • Previous by thread: function arguments as subscripts
  • Next by thread: Can someone explain this?