MathGroup Archive 1998

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

Search the Archive

What to return on symbolic evaluation of own heads ?


  • To: mathgroup@smc.vnet.net
  • Subject: [mg12511] What to return on symbolic evaluation of own heads ?
  • From: Andreas Keese <a.keese@tu-bs.de>
  • Date: Sat, 23 May 1998 18:10:43 -0400
  • Organization: Institute of scientific computing, TU BS

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: help about klotoid-integral-solution
  • Next by Date: Re: Grid Box help needed
  • Prev by thread: Re: AFM files not found
  • Next by thread: RE: What to return on symbolic evaluation of own heads ?