MathGroup Archive 1996

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

Search the Archive

Re: Problem with condition in function definition !

  • To: mathgroup at
  • Subject: [mg4221] Re: [mg4149] Problem with condition in function definition !
  • From: Allan Hayes <hay at>
  • Date: Tue, 18 Jun 1996 03:26:51 -0400
  • Sender: owner-wri-mathgroup at

a_kowald at (Axel Kowald)
[mg4149] Problem with condition in function definition !

>I'd like to define a function with condition in the following way:
>bla[t_]/;(t<b) := {a,b,c}
>bla[0] gives {a,b,c}, fine. But now I want to clear b, Clear[b],  
and >still get the same result. So really I want to type 1 instead  
of b, >but for some reason can't do it.


I'm not sure why you can't type 1 instead of b; it works for me.

After entering
   	bla[t_]/;(t<b) := {a,b,c}
The infomation stored on bla and on b is
		bla[t_] /; t < b := {a, b, c}

b is not evaluated because.
		b = 1
When  we evaluate bla[0] the condition t<b becomes first 0<b, then  
0<1, then True; so we get {a,1,c}
		{a, 1, c}
The change of b to 1 was  because of the information stored on b.
Now clear b
No rule is stored under b
So now, when bla[a] is evaluated the condition becomed 0<b and  
stays at this values - this is not True so the condition fails and  
no rule is applied
You have the flexibility to define b to be whatever you want:
	b = 3;
		{a, 3, c}
If you don't want this flexiblity then you can use
	bla[t_]/;(t<1) := {a,b,c}
	bla[t_]/;(t<1) := {a,1,c}

Allan Hayes
hay at


  • Prev by Date: Re: How can this MapAt application be done more efficiently
  • Next by Date: Error Bars in ListPlot
  • Previous by thread: Re: Problem with condition in function definition !
  • Next by thread: Announcing TMath: Tcl and C++ Interfaces to Mathematica