fac.red 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. module fac; % Support "factor" as an operator.
  2. % Author: Anthony C. Hearn.
  3. global '(!*micro!-version);
  4. symbolic procedure factor u;
  5. if !*micro!-version then factor0 u else factor1(u,t,'factors!*);
  6. symbolic procedure factor0 u;
  7. begin scalar oldexp,v,w;
  8. if cdr u or kernp (v := simp!* car u)
  9. then <<lprim "Please use FAC instead";
  10. return factor1(u,t,'factors!*)>>;
  11. oldexp := !*exp;
  12. !*exp := t;
  13. if null oldexp then v := resimp v;
  14. w := !*fcfm2f fctrf numr v ./ !*fcfm2f fctrf denr v;
  15. if null oldexp then !*exp := oldexp;
  16. % if w = u or w = v then return u
  17. % else if null oldexp then return mk!*sq w
  18. % else return list('!*sq,w,nil)
  19. return mk!*sq w
  20. end;
  21. flag('(factor),'intfn);
  22. symbolic procedure !*fcfm2f u;
  23. % converts factored form u to standard form.
  24. multf(car u,!*fcfm2f1 cdr u);
  25. symbolic procedure !*fcfm2f1 u;
  26. if null u then 1 else multpf(mksp(caar u,cdar u),!*fcfm2f1 cdr u);
  27. symbolic procedure expandd u; reval u where !*exp = t;
  28. flag('(expandd),'opfn);
  29. flag('(expandd),'noval);
  30. endmodule;
  31. end;