Combining several pure functions into a single pure function

*To*: mathgroup at smc.vnet.net*Subject*: [mg7262] Combining several pure functions into a single pure function*From*: r.lawrence at worldnet.att.net (Robert Lawrence)*Date*: Tue, 20 May 1997 02:59:04 -0400 (EDT)*Organization*: AT&T WorldNet Services*Sender*: owner-wri-mathgroup at wolfram.com

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)] The only generally-applicable method that I have found to do this is to arrange things so that each individual pure function, when generated, is placed inside a wrapper -- so that the group would initially look like this: temp= (wrap[Function[x,Plus[x]>9]] && wrap[Function[x,Length[x]==4]]) || (wrap[Function[x,Plus[x]<3]] && wrap[Function[x,Length[x]==6]]) I then produce the function I need by writing: Function[x,(temp /. wrap[expr_] -> expr[x])] This approach works fine but seems slightly convoluted. I'm wondering if anyone knows of a more straightforward way of accomplishing this. Bob Lawrence