Mathematica 9 is now available
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

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

  • To: mathgroup at smc.vnet.net
  • Subject: [mg74430] Re: Function[x...] and #& not equivalent
  • From: "wooks" <wookiz at hotmail.com>
  • Date: Wed, 21 Mar 2007 02:47:59 -0500 (EST)
  • References: <etof3e$i3d$1@smc.vnet.net>

On Mar 20, 11:04 am, "wooks" <woo... at hotmail.com> wrote:
> 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


Ignore this ... i've seen the error.



  • Prev by Date: Re: Keyboard shortcut to select the entire cell
  • Next by Date: Re: Using legend with FilledPlot
  • Previous by thread: Function[x...] and #& not equivalent
  • Next by thread: Re: Function[x...] and #& not equivalent