Re: Condition for pure functions
- To: mathgroup at smc.vnet.net
- Subject: [mg59799] Re: Condition for pure functions
- From: Bill Rowe <readnewsciv at earthlink.net>
- Date: Mon, 22 Aug 2005 02:48:16 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
On 8/21/05 at 3:51 AM, wssaca at gmail.com (Wonseok Shin) wrote:
>Suppose that f[x] is defined as:
>f[x_ /; x > 0] := Sin[x];
>f[x_ /; x <= 0] := Tan[x];
>How can transform the above definition into a pure function?
>I know
>f = Which[# > 0, Sin[#], # <= 0, Tan[#]] &
>is a one solution.
Other solutions would be
f = (1 - UnitStep[#])Tan[#] + UnitStep[#]Sin[#]&
or
f = Piecewise[{{Sin[#], # > 0}, {Tan[#], # <= 0}}] &
--
To reply via email subtract one hundred and four