reclist.py 491 B

1234567891011121314151617181920212223242526272829
  1. class pol(list):
  2. def __init__(self,s):
  3. if isinstance(s,str):
  4. self.extend([0,1,s])
  5. elif isinstance(s,pol):
  6. self.extend(s)
  7. def copy(self):
  8. n=pol(self)
  9. if isinstance(n[0],pol):
  10. n[0]=n[0].copy()
  11. if isinstance(n[1],pol):
  12. n[1]=n[1].copy
  13. return n
  14. def __add__(a,b):
  15. a=a.copy()
  16. if isinstance(b,float):
  17. a[0]+=b
  18. return a
  19. def __mul__(a,b):
  20. a=a.copy()
  21. if isinstance(b,float):
  22. a[0]*=b
  23. a[1]*=b
  24. return a