MathGroup Archive 2002

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

Search the Archive

Re: rightTree[tree[_, _, right_]] := right Hu?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg38025] Re: rightTree[tree[_, _, right_]] := right Hu?
  • From: Tom Burton <tburton at brahea.com>
  • Date: Tue, 26 Nov 2002 00:49:07 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

On 11/24/02 11:00 PM, in article arshqs$ea1$1 at smc.vnet.net, "Steven T.
Hatton" <hattons at globalsymmetry.com> wrote:

> 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?

How about "rightTree returns the third element of a three-element expression
headed by 'tree'"?

Think Lisp (I date myself :-). Lower your mental wall between functions and
data. "Everything is an expression" [The Mathematica Book section 2.1.1]. In
the example above, rightTree resembles a function, and tree resembles a
structure, but these apparent roles could (in principle) reverse elsewhere.
If tree also evaluates as a function, then the expression above would still
work if rightTree has the HoldAll or HoldFirst attribute.

Tom Burton



  • Prev by Date: Re: Data Conversion
  • Next by Date: Re: rightTree[tree[_, _, right_]] := right Hu?
  • Previous by thread: Re: rightTree[tree[_, _, right_]] := right Hu?
  • Next by thread: Re: rightTree[tree[_, _, right_]] := right Hu?