MathGroup Archive 1998

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

Search the Archive

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



Hallo Andreas,

MyCharFunc[left_, right_, var_?NumberQ]:=If[left<=var<=right,1,0]

Jrgen

-----Original Message-----
From: Andreas Keese <a.keese@tu-bs.de> To: mathgroup@smc.vnet.net
Subject: [mg12608] [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: About plotting a surface
  • Next by Date: Re: Newbe: Wave equation
  • Prev by thread: Re: What to return on symbolic evaluation of own heads ?
  • Next by thread: Re: What to return on symbolic evaluation of own heads ?