constantp and featurep



-----maxima-bounces at math.utexas.edu wrote: -----

>(%i1)?declare(A,constant);?featurep(A,constant);?constantp(A);
>
>(%o1)?done
>(%o2)?false
>(%o3)?true
>
>
>Would?it?be?possible?to?add?`constant'?to?the?list?of?features?that
>`featurep'?can?answer?correctly?by?farming?the?query?out?to?`constantp'?

Yes, this can be done by adding one line of code to featurep. But I'm not
sure it is a good thing to do. Having distinct ways of doing the same
thing causes chaos---somebody appends a bit of code to featurep but
not constantp; users don't know which to use; and ...

I think featurep was intended to be a function that simply checked the
fact database. Now, I'm not sure there is a way for a user to just as
if a fact is in the fact database.  And that's not good.


Barton

(defmfun $featurep (e ind)
  (setq e ($ratdisrep e))
  (cond ((not (symbolp ind)) (merror (intl:gettext "featurep: second
  argument must be a symbol; found ~M") ind))
 ((eq ind '$integer) (maxima-integerp e))
 ((eq ind '$noninteger) (nonintegerp e))
 ((eq ind '$even) (mevenp e))
 ((eq ind '$odd) (moddp e))
 ((eq ind '$real)
  (if (atom e)
      (or (numberp e) (kindp e '$real) (numberp (numer e)))
      (free ($rectform e) '$%i)))
 ((eq ind '$constant) ($constantp e)) ;; added code
 ((eq ind '$complex) t)
 ((symbolp e) (kindp e ind))))