The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Inactive » comp.soft-sys.math.mathematica

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Re: [mg4149] Problem with condition in function definition !
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
Allan Hayes

Posts: 1,508
Registered: 12/6/04
Re: [mg4149] Problem with condition in function definition !
Posted: Jun 16, 1996 2:08 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply (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

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.