Skip to main content
replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/
Source Link

You want to use Set rather than SetDelayed

Clear[f]

f[x_, y_] := x + 3 y /. {x -> -x y}

DownValues[f]

(*  {HoldPattern[f[x_, y_]] :> (x + 3 y /. {x -> -x y})}  *)

Trace will show you the evaluation sequence

f[1, 2] // Trace

enter image description here

Clear[f]

f[x_, y_] = x + 3 y /. {x -> -x y}

(*  3 y - x y  *)

DownValues[f]

(*  {HoldPattern[f[x_, y_]] :> 3 y - x y}  *)

f[1, 2] // Trace

enter image description here

Beware that if x or y are defined before the Set this will fail. For a solution see:

You want to use Set rather than SetDelayed

Clear[f]

f[x_, y_] := x + 3 y /. {x -> -x y}

DownValues[f]

(*  {HoldPattern[f[x_, y_]] :> (x + 3 y /. {x -> -x y})}  *)

Trace will show you the evaluation sequence

f[1, 2] // Trace

enter image description here

Clear[f]

f[x_, y_] = x + 3 y /. {x -> -x y}

(*  3 y - x y  *)

DownValues[f]

(*  {HoldPattern[f[x_, y_]] :> 3 y - x y}  *)

f[1, 2] // Trace

enter image description here

Beware that if x or y are defined before the Set this will fail. For a solution see:

You want to use Set rather than SetDelayed

Clear[f]

f[x_, y_] := x + 3 y /. {x -> -x y}

DownValues[f]

(*  {HoldPattern[f[x_, y_]] :> (x + 3 y /. {x -> -x y})}  *)

Trace will show you the evaluation sequence

f[1, 2] // Trace

enter image description here

Clear[f]

f[x_, y_] = x + 3 y /. {x -> -x y}

(*  3 y - x y  *)

DownValues[f]

(*  {HoldPattern[f[x_, y_]] :> 3 y - x y}  *)

f[1, 2] // Trace

enter image description here

Beware that if x or y are defined before the Set this will fail. For a solution see:

added 148 characters in body
Source Link
Mr.Wizard
  • 273.1k
  • 34
  • 595
  • 1.4k

You want to use Set rather than SetDelayed

Clear[f]

f[x_, y_] := x + 3 y /. {x -> -x y}

DownValues[f]

(*  {HoldPattern[f[x_, y_]] :> (x + 3 y /. {x -> -x y})}  *)

Trace will show you the evaluation sequence

f[1, 2] // Trace

enter image description here

Clear[f]

f[x_, y_] = x + 3 y /. {x -> -x y}

(*  3 y - x y  *)

DownValues[f]

(*  {HoldPattern[f[x_, y_]] :> 3 y - x y}  *)

f[1, 2] // Trace

enter image description here

Beware that if x or y are defined before the Set this will fail. For a solution see:

You want to use Set rather than SetDelayed

Clear[f]

f[x_, y_] := x + 3 y /. {x -> -x y}

DownValues[f]

(*  {HoldPattern[f[x_, y_]] :> (x + 3 y /. {x -> -x y})}  *)

Trace will show you the evaluation sequence

f[1, 2] // Trace

enter image description here

Clear[f]

f[x_, y_] = x + 3 y /. {x -> -x y}

(*  3 y - x y  *)

DownValues[f]

(*  {HoldPattern[f[x_, y_]] :> 3 y - x y}  *)

f[1, 2] // Trace

enter image description here

You want to use Set rather than SetDelayed

Clear[f]

f[x_, y_] := x + 3 y /. {x -> -x y}

DownValues[f]

(*  {HoldPattern[f[x_, y_]] :> (x + 3 y /. {x -> -x y})}  *)

Trace will show you the evaluation sequence

f[1, 2] // Trace

enter image description here

Clear[f]

f[x_, y_] = x + 3 y /. {x -> -x y}

(*  3 y - x y  *)

DownValues[f]

(*  {HoldPattern[f[x_, y_]] :> 3 y - x y}  *)

f[1, 2] // Trace

enter image description here

Beware that if x or y are defined before the Set this will fail. For a solution see:

Source Link
Bob Hanlon
  • 162.7k
  • 7
  • 81
  • 205

You want to use Set rather than SetDelayed

Clear[f]

f[x_, y_] := x + 3 y /. {x -> -x y}

DownValues[f]

(*  {HoldPattern[f[x_, y_]] :> (x + 3 y /. {x -> -x y})}  *)

Trace will show you the evaluation sequence

f[1, 2] // Trace

enter image description here

Clear[f]

f[x_, y_] = x + 3 y /. {x -> -x y}

(*  3 y - x y  *)

DownValues[f]

(*  {HoldPattern[f[x_, y_]] :> 3 y - x y}  *)

f[1, 2] // Trace

enter image description here