MathGroup Archive 2010

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

Search the Archive

Re: Re: What does & mean?

  • To: mathgroup at
  • Subject: [mg107266] Re: [mg107239] Re: What does & mean?
  • From: DrMajorBob <btreat1 at>
  • Date: Sun, 7 Feb 2010 06:13:31 -0500 (EST)
  • References: <> <hkgks4$6p9$>
  • Reply-to: drmajorbob at

I think things like Sin@#& are functions (more or less), whereas things  
like f in


are pattern-matching rule sets.

Neither way of defining things gives mathematical functions, in general,  
since both can carry the same input to different outputs on subsequent  

That is, f in

f = (i++;i #)&

is not a function mathematically, and neither is


Hence, to my mind, trying to label one of the two forms a "true function"  
and the other one "not a true function" is fruitless.


On Sat, 06 Feb 2010 02:25:21 -0600, Richard Fateman  
<fateman at> wrote:

> Leonid Shifrin wrote:
>> Richard,
>>     Leonid's confusion relates to the pseudo-definition of a
>>     "function" by pattern matching using
>>     fn[arg_]:= .......
>>     and the definition of a true function by
>>     fn= Function[{arg}], ......]   or the brief but obscure ...#..&
>>     notation...
>>     fn = ....#.... &
>>     There is a widely held but technically bogus equivalence in the  
>> minds
>>     of Mathematica users, so Leonid's not alone..
>>     In particular, there is no pattern matching going on in the fn=
>>     ... case, and the SetAttribute[fn, HoldAll] has no effect  
>> whatsoever.
>> Can it be that you are not aware of the syntax of pure functions in
>> Mathematica which allows to set Hold-attributes (Function[vars,body,
>> HoldAll] for instance)?  But more to the point.
> In fact, I was unaware of this feature, which I suspect was added to the
> language sometime after version 2 or 3.  I was also unaware
> of the possibility of using ##  for SlotSequence.
> This does not change the fact that SetAttribute[fn,HoldAll] has no
> effect on fn.
> I was unaware of your book (available online free! Thanks!) which looks
> rather nice.  But there is
> generally a trade-off between being "friendly" and being "accurate".
> Thus using the term "function"
> is tricky.  You can use a bunch of rules to define what is conceptually
> a mathematical function ...
> a pure mapping from input to output..  or you can talk about a
> "programming language function" which
> is (loosely speaking) any procedure, perhaps with side effect,  that
> returns a value..
> or you can talk about a Mathematica Function, or   something (....)&,
> which is a syntactic/ evaluation
> convention that by-passes pattern matching.
> Much of the discussion (not really in response to the original posting
> -- he just wanted to know how to
> get help on the "&" symbol, I think) .. has concentrated on the
> evaluation semantics in Mathematica,
> which gets in the way of many programmers. How many times do you
> evaluate a symbol?
> If you type x=x+1, you  see it is about 255 times.  This causes problems
> that eventually get solved
> by trying to block evaluation, sometimes, and then in some controlled
> way, Releasing it.
> Using Functions is a way to help do this,  though it can be seen more
> cleanly in "functional programming"
> languages. I do not know of any (non-Mathematica)  functional language  
> with this
> "evaluate forever"
> semantics, though variants of it are common in rule-based transformation
> languages.
>> If you'd care to look at the relevant sections of my book you'd see
>> that I clearly state that pure and pattern-defined functions are very
>> different and used for different purposes (In fact, I had a couple of
>> examples similar to yours to illustrate this).
> I looked and yes you do.
> ... snip....
>> fn1 =
>>   Function[{arg},
>>    Switch[Head[Unevaluated[arg]], Print, "You want to print", Times,
>>     "You want to multiply", _, "I have no idea what you want to do"],
>>    HoldAll];
> ....
>> To my mind,  this explanation should have  left no room for further
>> ambiguities,
> .. much better example...
> And thanks for mentioning your book, which I had not seen before. It
> seems to have good insights.  (I admit to not
> reading its predecessors except the one by Maeder).

DrMajorBob at

  • Prev by Date: Re: Could you prove this proposition:the i-th prime gap p[i+1]-p[i]<=i
  • Next by Date: Re: Could you prove this proposition:the i-th prime gap
  • Previous by thread: Re: Re: What does & mean?
  • Next by thread: Re: Re: Re: What does & mean?