MathGroup Archive 2009

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

Search the Archive

Re: If and ReplaceAll

  • To: mathgroup at smc.vnet.net
  • Subject: [mg102846] Re: If and ReplaceAll
  • From: Harutyun Amirjanyan <amirjanyan at gmail.com>
  • Date: Sun, 30 Aug 2009 06:06:28 -0400 (EDT)
  • References: <h7b08h$gq$1@smc.vnet.net>

If has an attribute HoldRest so when z>0 isn't True or False  there is
no c in f[z].

to get If[z > 0, 2, 0] you should somhow evaluate "a" first

f[z_] := If[z > 0, Evaluate@a, 0]
f[z] /. c -> 1

or

f[z_] := If[z > 0, a, 0]
f[z] /. If[a1_, a2__] :> If[a1, Evaluate@a2] /. c -> 1

and you'll get almost what you want: If[z > 0, 2 1, 0]


  • Prev by Date: Re: if only one of u,v parameter lines is to be shown in 3D
  • Next by Date: avi and QuickTime
  • Previous by thread: Re: If and ReplaceAll
  • Next by thread: Re: If and ReplaceAll