dipprint.red 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. module dipprint; %/* printing routines for distributive polynomials*/
  2. %/*Authors: R. Gebauer, A. C. Hearn, H. Kredel*/
  3. fluid '(dipvars!*);
  4. expr procedure diplprint u;
  5. % /* Prints a list of distributive polynomials using dipprint*/
  6. for each v in u do dipprint v;
  7. expr procedure dipprint u;
  8. % /* Prints a distributive polynomial in infix form*/
  9. <<terpri(); dipprint1(u,nil); terpri(); terpri()>>;
  10. expr procedure dipprint1(u,v);
  11. % /* Prints a distributive polynomial in infix form.
  12. % U is a distributive form. V is a flag which is true if a term
  13. % has preceded current form*/
  14. if dipzero!? u then if null v then dipprin2 0 else nil
  15. else begin scalar bool,w;
  16. w := diplbc u;
  17. if bcminus!? w then <<bool := t; w := bcneg w>>;
  18. if bool then dipprin2 " - " else if v then dipprin2 " + ";
  19. (if not bcone!? w or evzero!? x then <<bcprin w; dipevlpri(x,t)>>
  20. else dipevlpri(x,nil))
  21. where x = dipevlmon u;
  22. dipprint1(dipmred u,t)
  23. end;
  24. expr procedure dipprin2 u;
  25. % /* Prints u, preceding by two EOL's if we have reached column 70*/
  26. <<if posn()>69 then <<terpri(); terpri()>>; prin2 u>>;
  27. endmodule;
  28. end;