MathGroup Archive 2005

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

Search the Archive

Condition for pure functions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg59797] Condition for pure functions
  • From: "Wonseok Shin" <wssaca at gmail.com>
  • Date: Sun, 21 Aug 2005 03:51:55 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Hello everyone,

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.  But is there any clever way to use Condition (/;)
instead of Which[...] ?


  • Prev by Date: adjust magnification of notebook to a value other than one of the predefined values?
  • Next by Date: partial derivative of a sum
  • Previous by thread: Re: adjust magnification of notebook to a value other than one of the predefined values?
  • Next by thread: Re: Condition for pure functions