Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1998
*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 1998

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

Search the Archive

Re: 2nd level pure function


  • To: mathgroup@smc.vnet.net
  • Subject: [mg11086] Re: 2nd level pure function
  • From: daiyanh@mindspring.com (Daitaro Hagihara)
  • Date: Sun, 22 Feb 1998 14:55:12 -0500
  • Organization: MindSpring Enterprises
  • References: <6c3bsc$18l@smc.vnet.net>

In article <6c3bsc$18l@smc.vnet.net>, richard nathan linger 
<rlinger@students.uiuc.edu> wrote:

> I am having a problem with explicit functions.  I am trying to write a
> procedure that returns a function that returns a function.  I would
> like to have it return this as a pure function.  I am not sure how to
> do this. 
>  
> I will state this problem another way; I know that if f[a]=4+a, then as
> a pure function, f is analagous to Function[4 + Slot[1]].  I want to
> know how to represent f as a pure function when f[a][b]=a+b; 
> 
> Nathan Linger
> Sophomore
> University of Illinois 

First I'd like to start out by saying that I don't know of any way to
produce nested pure functions using standard built-in commands.  Maybe
folks at WRI can give you some guides on this.

Second it may be a bad idea to make programs heavily dependent on pure
functions since dealing with them is a "pure" pain in the ass.  Having
just a few of them around makes me quite nervous as the ominous
anticipation of using Distributes's and Through's and Operate's becomes
increasingly clear.

Third by going through some of the things you posted, I found out a
certain degree of anomalies besides what you've found.  E.g., while
Block[{x=#},x]& works as expected, Block[{x=#},x+#&]& doesn't work. 
This is puzzling since the defined function f[x_]=x+#& works.  But by
using Module instead of Block, everything worked except the
intermediate pure function looks funny.

So, my (partial) answer to your question is: Module[{x=#},x+#&]&

Note: This is verified only on v.2.2.

Daitaro Hagihara



  • Prev by Date: Re: Mathematica as a programing environment
  • Next by Date: Re: TeXForm, OutputForm questions ?
  • Prev by thread: RE: 2nd level pure function
  • Next by thread: Re: 2nd level pure function