Re: Re: Mathematica scoping / contexts / variable localization
- To: mathgroup at smc.vnet.net
- Subject: [mg105154] Re: [mg105135] Re: Mathematica scoping / contexts / variable localization
- From: "David Park" <djmpark at comcast.net>
- Date: Mon, 23 Nov 2009 06:48:57 -0500 (EST)
- References: <32142906.1258547432910.JavaMail.root@n11> <he36g8$efk$1@smc.vnet.net> <he88nu$prb$1@smc.vnet.net> <31695084.1258894017394.JavaMail.root@n11>
It's called SubValues. One advantage is that it cleanly separates parameters from variables. Another is that you can write expressions such as: f[a, b]'[x] You can also use it conveniently as a postfix operator: x//f[a, b] There would be many operations in Mathematica that would be easier to use if they were defined with SubValues. For example the various GeometricTransformations are inconvenient in their present form because they have to be wrapped around a piece of graphics. Postfix operation would be more convenient. (In Presentations I do provide alternative postfix forms of all these operators because we always have the primitive form of graphics available to operate on and it is convenient to define a basic form and then move it to its proper place.) But SubValues seems to be the poor orphan of Mathematica "Values". There is a usage message but no documentation page. I don't know of any tutorial for it. Command completion for SubValues definitions doesn't give the entire expression, which I think it should. And DocuTools doesn't handle it properly. WRI seems to avoid SubValues in any of their basic functions. I don't know if there is a good reason for this. You can type SubValues in the DC SEARCH box and then use "Try your search on all Wolfram sites" to get a fair amount of MathGroup discussion about SubValues. The saying is: "Give a hungry man a fish and he'll be back the next day. Teach a hungry man to fish and you won't see him again for two or three days - if he hasn't drowned in the meantime." David Park djmpark at comcast.net http://home.comcast.net/~djmpark/ From: AES [mailto:siegman at stanford.edu] > > Clear[a, b] > > > > ClearAll[f] > > f[a_, b_][x_] := Exp[-a x] Sin[b x] I've seen this more complex form of function definition go by once or twice in the past, but never used it or learned about it myself. Pointers to tutorial explanations? [Or, more challenging, an explanation, in classic "teach a man to fish" mode, of how a mythical "ordinary user" might go about quickly and efficiently _finding_ such tutorial explanations, for this specific case, in Mathematica documentation.]