MathGroup Archive 1994

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

Search the Archive

Combining pure functions..

  • To: mathgroup at
  • Subject: [mg349] Combining pure functions..
  • From: kaufman1 at (Al Kaufman)
  • Date: Wed, 21 Dec 1994 10:08:03 -0800

Xah Lee asks:

>Is there a way to combine several pure functions algebraicaly as one pure

>One Example:

>How to get (#^2&)/(#^3&) to become (#^2/#^3)&

This is an interesting problem.

There are two notations used for pure functions.  One is noted in the example:
#^2& // FullForm is given as: Function[Power[Slot[1],2]]  an equivalent form is
given using a dummy variable x:  Function[x,Power[x,2]];

However, there is not a unique solution here without specifying what the
external relationship between the arguments to pure functions should be. In
other words should an expression e[f1,f2] involving: f1 =
Function[{x1},body1] and f2 = Function[{x2},body2] which involve dummy
variables x1 and x2 respectively be mapped to
Function[{x1,x2},e[f1[x1],f2[x2]] or in the simplest form:

Here is a solution invoking the latter assumption in which the dummy
variables are presumed identical.

ComposePureFunctions[e_] :=
        With[{body$ = e/.p:Function[__] :> p[dummy$]},

We apply to the example:


and obtain:


the desired result.

Al Kaufman
Lawrence Livermore National Lab
Mail stop L-83
Livermore, Ca  94550
Phone:  510-422-1599
FAX:    510-422-8471
E-mail: <kaufman1 at>
Alt. e-mail: <nutronstar at>

  • Prev by Date: Re: Web pages
  • Next by Date: Alternating Series Construct
  • Previous by thread: Possible error in $PreRead???
  • Next by thread: Re: Combining pure functions..