MathGroup Archive 1996

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

Search the Archive

Re-evaluation of Conditional expressions

  • To: mathgroup at
  • Subject: [mg3460] Re-evaluation of Conditional expressions
  • From: quinton at (Patrice Quinton)
  • Date: Sat, 9 Mar 1996 00:59:03 -0500
  • Organization: IRISA, Campus de Beaulieu, 35042 Rennes Cedex, FRANCE
  • Sender: owner-wri-mathgroup at

While teaching Mathematica, I found the following quite strange
behaviour of Conditional expressions in Mathematica. Define symbol y as follows:

y = If[x,1,2]

(* Then set x to True and revaluate y *)

(* as expected, the answer is 1 *)
(* Now, set x to z, a fresh symbol, and evaluate y *)

(* The result is If[x,1,2] *)

(* Finally, set z to True, and evaluate y *)

The result is still If[x,1,2], although a re-evaluation of x gives True, as

The only way to get a re-evaluation of y is to use the function Update:


which gives the result 1. In summary, it seems that If is re-evaluated only if
the expression that assigned to x has changed, and not when the value of x has

Is there a special reason for this? Any way to circumvent this problem?


Patrice Quinton 

Irisa, Campus de Beaulieu,
University of Rennes 1, France
Phone: 99 84 71 85, Fax: 99 84 71 71


  • Prev by Date: Re: Q: Getting interspike intervals in neuronal firing patterns
  • Next by Date: Re: "Do" help
  • Previous by thread: Kernel crashing with error 11 ??
  • Next by thread: Re: Re-evaluation of Conditional expressions