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

MathGroup Archive 1997

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

Search the Archive

Re: Combining several pure functions into a single pure function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg7295] Re: Combining several pure functions into a single pure function
  • From: tburton at cts.com (Tom Burton)
  • Date: Thu, 22 May 1997 09:20:01 -0400 (EDT)
  • Organization: Brahea Consulting
  • Sender: owner-wri-mathgroup at wolfram.com

On 20 May 1997 02:59:43 -0400, in comp.soft-sys.math.mathematica you wrote:

>I am working with a little program that generates several pure
>functions which are "Boolean" in nature -- i.e., each of them, when
>applied to an argument, evaluates to True or False.  These functions,
>when they are initially produced, are connected with logical operators
>-- for example:
>
>	(Function[x,Plus[x]>9] && Function[x,Length[x]==4]) ||
>	(Function[x,Plus[x]<3] && Function[x,Length[x]==6])
>
>In this form, however, they are useless since, as a group, they do not
>constitute a pure function and cannot be applied to an argument.
>Thus, I need to convert the foregoing into a single pure Boolean
>function, which would (using the above example) look like this:
>
>	Function[x,(Plus[x]>9 && Length[x]==4) || 
>	(Plus[x]<3 && Length[x]==6)]
>
Here's a slightly simpler form. Just stick [x] at the end of each function and then wrap the resulting expression in Function[x,#]:

vv = Function[x,
       Function[x,Plus@@x>9]    [x] && 
       Function[x,Length[x]==4] [x] ||
       Function[x,Plus@@x<3]    [x] && 
       Function[x,Length[x]==6] [x]    
     ]

By the way, I substituted Plus@@x for Plus[x] to make sense of this.  Is x a list or not? I assumed is.

Cheers,


Tom Burton


  • Prev by Date: AW: StyleForm, and other bugs...
  • Next by Date: Re: Font-Installation ?
  • Previous by thread: Re: Combining several pure functions into a single pure function
  • Next by thread: Re: Combining several pure functions into a single pure function