Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2001
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2001

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

Search the Archive

Re: Should Pure Functions Require &

  • To: mathgroup at smc.vnet.net
  • Subject: [mg29731] Re: [mg29723] Should Pure Functions Require &
  • From: Andrzej Kozlowski <andrzej at tuins.ac.jp>
  • Date: Thu, 5 Jul 2001 06:07:58 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

It depends what you mean. There are certainly lots of cases where & is
needed.  E.g. how would you distinguish:

In[1]:=
Array[f,{3}]

Out[1]=
{f[1],f[2],f[3]}

In[2]:=
Array[f&,{3}]

Out[2]=
{f,f,f}

In[3]:=
Array[(f&)&,{3}]

Out[3]=
{f&,f&,f&}

Here is another example:

In[1]:=
Composition[#,#&]&[f][2]
Out[1]=
f[2]

In[2]:=
Composition[#,#]&[f][2]
Out[2]=
f[f[2]]

(There are more important examples, I made these up in a couple of minutes).
So making & optional would mean that Mathematica would have to choose an
interpretation in all the ambiguous cases and the user would then have to
work out what went wrong by himself and insert the needed &. Sounds like bad
interface to me.

Andrzej Kozlowski


on 01.7.5 7:43 AM, Ersek, Ted R at ErsekTR at navair.navy.mil wrote:

> I stated wondering if all would work well if pure functions didn't require &
> at the end. I am thinking it would be great if a future version of
> Mathematica would make the use of & optional.
> 
> So for example we could use
> Select[data, #!=0]
> instead of 
> Select[data, #!=0&]
> 
> 
> and we could use 
> #^2 /@expr
> instead of 
> #^2& /@expr
> 
> I would want to have pure functions ending with & optional rather than
> prohibited for backward compatibility.  Wouldn't life be better if we didn't
> have to use &. Is there a reason why my suggestion would not work?
> 
> Regards,
> Ted Ersek
> Download Mathematica tips, tricks from
> http://www.verbeia.com/mathematica/tips/Tricks.html
> 
> 
> 

-- 
Andrzej Kozlowski
Toyama International University
JAPAN

http://platon.c.u-tokyo.ac.jp/andrzej/
http://sigma.tuins.ac.jp/~andrzej/



  • Prev by Date: Re: Drawing a Washer, Polar Plot Question
  • Next by Date: RE: Drawing a Washer, Polar Plot Question
  • Previous by thread: Should Pure Functions Require &
  • Next by thread: Re: Should Pure Functions Require &