home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / e / e032 / 3.ddi / FILES / PROGRAMM.PAK / ALGEXP.M next >
Encoding:
Text File  |  1992-07-29  |  787 b   |  32 lines

  1.  
  2. (*********************************************************************
  3.  
  4.         Adapted from
  5.         Roman E. Maeder: Programming in Mathematica,
  6.         Second Edition, Addison-Wesley, 1991.
  7.  
  8.  *********************************************************************)
  9.  
  10.  
  11. AlgExpQ::usage = "AlgExpQ[expr] returns true if expr is an algebraic expression."
  12.  
  13. Begin["`Private`"]
  14.  
  15. SetAttributes[AlgExpQ, Listable]
  16.  
  17. AlgExpQ[ _Integer ]  = True
  18. AlgExpQ[ _Rational ] = True
  19. AlgExpQ[ c_Complex ] := AlgExpQ[Re[c]] && AlgExpQ[Im[c]]
  20. AlgExpQ[ _Symbol ]   = True
  21.  
  22. AlgExpQ[ a_ + b_ ] := AlgExpQ[a] && AlgExpQ[b]
  23. AlgExpQ[ a_ * b_ ] := AlgExpQ[a] && AlgExpQ[b]
  24. AlgExpQ[ a_ ^ b_Integer ]  := AlgExpQ[a]
  25. AlgExpQ[ a_ ^ b_Rational ] := AlgExpQ[a]
  26.  
  27. AlgExpQ[_] = False
  28.  
  29. End[]
  30.  
  31. Null
  32.