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

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

Search the Archive

RE: Functional Expression Meaning (was:A Functional Expression Trick)

  • To: mathgroup at smc.vnet.net
  • Subject: [mg23931] RE: Functional Expression Meaning (was:[mg23859] A Functional Expression Trick)
  • From: "David Park" <djmp at earthlink.net>
  • Date: Fri, 16 Jun 2000 00:57:12 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com


> -----Original Message-----
> From: Allan Hayes [mailto:hay at haystack.demon.co.uk]
To: mathgroup at smc.vnet.net
> Dear David and Hartmut,
> I have come across some problems with Hartmut's solution, toFunc,
> as written
> up by David.
> I offer new version, toFunc2
>

Dear Allan and Hartmut,

Allan's solution is more robust than Hartmut's, but it leaves out the case
of pure functions in short form, using slot numbers directly. So I added an
extra rule for that case. Here is it:

toFunc::usage =
    "toFunc[expr] will convert an expression of pure functions into a pure \
function.";
toFunc[expr_] :=
  ReleaseHold[Function @@ ({expr} /.
          (F_ /; F === Function)[vars_, body_] :>
            Apply[F[vars, Hold[body]],
              Slot /@ Range[Last[Dimensions[Unevaluated[{vars}]]]]
                ]
          /. (F_ /; F === Function)[ body_] :> Hold[body]
        )]

I think this is a very useful routine. Thanks to both of you.

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/



  • Prev by Date: Manipulating List Elements In Programs
  • Next by Date: Re: Appending an element to a list
  • Previous by thread: RE: Functional Expression Meaning (was:A Functional Expression Trick)
  • Next by thread: Re: Functional Expression Meaning (was:A Functional Expression Trick)