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: [mg7327] Re: [mg7262] Combining several pure functions into a single pure function
  • From: Allan Hayes <hay at haystack.demon.co.uk>
  • Date: Fri, 23 May 1997 02:23:44 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

20 May 1997
r.lawrence at worldnet.att.net (Robert Lawrence)
[mg7262] Combining several pure functions into a single pure function
Organization: AT&T WorldNet Services

> -- for example:
>
>	(Function[x,Plus[x]>9] && Function[x,Length[x]==4]) ||
>	(Function[x,Plus[x]<3] && Function[x,Length[x]==6])
>
> 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)]

Bob,
Here is a variant of the method that you suggest

FunctionOut[x_,fl_]:=
	((Hold[x,fl]/.Function[x,body_]:> body)/.Hold->Function)

FunctionOut[x,(Function[x,Plus[x]>9] && Function[x,Length[x]==4]) ||
	(Function[x,Plus[x]<3] && Function[x,Length[x]==6])]

	Function[x,+x>9&&Length[x]==4||+x<3&&Length[x]==6]
	
Allan Hayes
hay at haystack.demon.co.uk
http://www.haystack.demon.co.uk/


  • Prev by Date: Re: Simple 3D Graph
  • Next by Date: Re: Multiple plots
  • Previous by thread: Using Sqrt[x_]/y_ ->
  • Next by thread: Headers and Footers