dip2a.red 937 B

1234567891011121314151617181920212223242526272829
  1. module dip2a;
  2. % Functions for converting distributive forms into prefix forms
  3. %Authors: R. Gebauer, A. C. Hearn, H. Kredel
  4. symbolic procedure dip2a u;
  5. % Returns prefix equivalent of distributive polynomial u.
  6. if dipzero!? u then 0 else dipreplus dip2a1 u;
  7. symbolic procedure dip2a1 u;
  8. if dipzero!? u then nil
  9. else ((if bcminus!? x then list('minus,dipretimes(bc2a bcneg x.y))
  10. else dipretimes(bc2a x.y))
  11. where x = diplbc u, y = expvec2a dipevlmon u)
  12. .dip2a1 dipmred u;
  13. symbolic procedure dipreplus u;
  14. if atom u then u else if null cdr u then car u else 'plus . u;
  15. symbolic procedure dipretimes u;
  16. % /* U is a list of prefix expressions the first of which is a number.
  17. % Result is prefix representation for their product*/
  18. if car u = 1 then if cdr u then dipretimes cdr u else 1
  19. else if null cdr u then car u
  20. else 'times.u;
  21. endmodule;;end;