MathGroup Archive 2009

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

Search the Archive

Re: If and ReplaceAll


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