MathGroup Archive 1998

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

Search the Archive

RE: What to return on symbolic evaluation of own heads ?


  • To: mathgroup@smc.vnet.net
  • Subject: [mg12611] RE: [mg12511] What to return on symbolic evaluation of own heads ?
  • From: "Barthelet, Luc" <lucb@ea.com>
  • Date: Mon, 25 May 1998 14:25:21 -0400

Here is what I would do:

F[x_] := MyCharFunc[0, 1, x]
MyCharFunc[left_, right_, var_/;NumberQ[var]] := 
   If[var < left || var > right, 0, 1]

It seems to do what you want.
F[x] return MyCharFunc[0,1,x]
while F[0.5] returns 1

Luc Barthelet
GM at day, Mayor at Night
Maxis.

> -----Original Message-----
> From:	Andreas Keese [SMTP:a.keese@tu-bs.de]
> Sent:	Saturday, May 23, 1998 3:11 PM
> To:	mathgroup@smc.vnet.net
> Subject:	[mg12511] What to return on symbolic evaluation of own
> heads ?
> 
> Hi, 
> 
> I'm trying to build my own Datatype - as an example, I'll try to
> construct a characteristic function. I define a characteristic
> function
> like this:
> 
> F[x_] := MyCharFunc[0,1,x]
> (* this is the char func of the interval [0,1] *)
> 
> And I try to define an evaluation-rule like this:
> 
> MyCharFunc[left_, right_, var_]:=
>   If[NumberQ[var],
>     If[var < left || var > right,
>       0,
>       1], (* else - symbolic variable *)
>     MyCharFunc[left, right, var]
>   ]
> 
> Of course, this doesn't work - while I can write F[0.5] and get a
> correct result, I can't write F[x] as this results in an infinite
> recursion --- but If I want to manipulate my data-object, I somehow
> need to return the original object. E.G. I want to be able to write
>    F[x] /. x-> 3
> and have this evaluated as F[3]...
> 
> What should I return in my evaluation-rule when the parameter is
> symbolic ?
> 
> Bye,
> Andreas



  • Prev by Date: Re: ListPlot?
  • Next by Date: Re: Electric Field around a Capacitor
  • Prev by thread: What to return on symbolic evaluation of own heads ?
  • Next by thread: Re: What to return on symbolic evaluation of own heads ?