       Re: Combining several pure functions into a single pure function

• To: mathgroup at smc.vnet.net
• Subject: [mg7297] Re: [mg7262] Combining several pure functions into a single pure function
• From: wself at viking.emcmt.edu (Will Self)
• Date: Thu, 22 May 1997 09:20:08 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```Bob Lawrence asked an interesting question about creating disjunctions
and conjunctions of pure functions.  In essence, I think, what is required
is a function disj that would accept two pure functions as arguments and
return a pure function.  The pure function returned would itself accept
two Boolean inputs and return their disjuntion.  To get around Bob's
difficulty, we can use Literal to prevent too-early evaluation of Function.

In:= disj[f1_,f2_]:=Function[x,Evaluate[f1[x] || f2[x] /.
Literal[Function[a_,b_]]->Function[a,b][x]]]

In:= g1=Function[x,x>0]

Out= Function[x, x > 0]

In:= g2=Function[y, y<2]

Out= Function[y, y < 2]

In:= disj[g1,g2]

Out= Function[x\$, x\$ > 0 || x\$ < 2]

In:= h=#<3&

Out= #1 < 3 &

In:= disj[g1,h]

Out= Function[x\$, x\$ > 0 || x\$ < 3]

Will Self
Montana

```

• Prev by Date: Re: Nonlinear Fit Problem
• Next by Date: PS printing problems: MMA V3.0 and Macs
• Previous by thread: Combining several pure functions into a single pure function
• Next by thread: Re: Combining several pure functions into a single pure function