Re: rightTree[tree[_, _, right_]] := right Hu?
- To: mathgroup at smc.vnet.net
- Subject: [mg38031] Re: rightTree[tree[_, _, right_]] := right Hu?
- From: "Allan Hayes" <hay at haystack.demon.co.uk>
- Date: Tue, 26 Nov 2002 00:49:50 -0500 (EST)
- References: <arshqs$ea1$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Steven, Mathematica may look like it uses functions but it is actually to do with the action of replacement rules on expressions. Thus, rightTree[tree[_, _, right_]] := right ( or for that matter rightTree[tree[_, _, r_]] := r) means: Store a rule so that when during the evaluation process an expression of the form rightTree[tree[_, _, x_]] is found, it is replaced by x The rule is stored in DownValues[rightTree] DownValues[rightTree] {HoldPattern[rightTree[tree[_,_,right_]]]:>right} The evaluation process is described in Appendix 4 (A.4) of the Book. -- Allan --------------------- Allan Hayes Mathematica Training and Consulting Leicester UK www.haystack.demon.co.uk hay at haystack.demon.co.uk Voice: +44 (0)116 271 4198 Fax: +44 (0)870 164 0565 "Steven T. Hatton" <hattons at globalsymmetry.com> wrote in message news:arshqs$ea1$1 at smc.vnet.net... > I found this: > rightTree[tree[_, _, right_]] := right > > in Dr. Mäder's Computer Science with Mathematica. I understand the spirit of > the statement, but it looks rather strange to me. Is there a way of > describing, in a language such as English, exactly what this definition > means? The part that I find confusing is the inclusion of what looks like a > function call in the parameter list. This simply defies my sense of how > programming languages work. That doesn't mean it's a bad thing. It just > means that I don't feel comfortable with the syntax. > > Is there somewhere in the Mathematica Book , or Help which discusses such > arcana? > > -- > STH > Hatton's Law: > "There is only One inviolable Law." > >