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

MathGroup Archive 2007

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

Search the Archive

Function[x...] and #& not equivalent

  • To: mathgroup at smc.vnet.net
  • Subject: [mg74420] Function[x...] and #& not equivalent
  • From: "wooks" <wookiz at hotmail.com>
  • Date: Tue, 20 Mar 2007 05:57:28 -0500 (EST)

In[19]:=
Clear[Eternity,x];
Eternity[x_]:=Eternity[x];

In[21]:=
Clear[EmptyQ];
EmptyQ[{}]:=True;
EmptyQ[x_List]:=False;
EmptyQ[x_]:=Print["Argument to EmptyQ must be a list."];

This below works for the empty list it gives 0.
In[25]:=
Clear[length,list]
Function[length,
      Function[list,If[EmptyQ[list],
                                               0,
                                               1 +
length[Rest[list]]]]][
    Eternity][{}]
Out[26]=
0

What I am trying to do here is pass the function above as the
definition of the parameter MkLength and then run the exactly the same
thing by MkLength[Eternity].
It doesn't work.
In[27]:=
Function[MkLength,MkLength[Eternity][Function[length,
               Function[list,If[EmptyQ[list],0,1 +
length[Rest[list]]]]]]][{}]

Out[27]=
{}[Eternity][
  Function[length,Function[list,If[EmptyQ[list],
0,1+length[Rest[list]]]]]]

But look what happens when I use the function abbreviation instead of
Function[MkLength........
In[29]:=
#[Eternity]&[Function[length,
         Function[list,If[EmptyQ[list],0,1 + length[Rest[list]]]]]]
[{}]
Out[29]=
0



  • Prev by Date: Re: Using legend with FilledPlot
  • Next by Date: Re: Slots & Ampersands
  • Previous by thread: Re: Is it possible to install the Workbench on a cluster
  • Next by thread: Re: Function[x...] and #& not equivalent