input: index (start at 0) output: the i-th component of the vector.
(self,i)
| 67 | """ |
| 68 | return "(" + ",".join(map(str, self.__components)) + ")" |
| 69 | def component(self,i): |
| 70 | """ |
| 71 | input: index (start at 0) |
| 72 | output: the i-th component of the vector. |
| 73 | """ |
| 74 | if type(i) is int and -len(self.__components) <= i < len(self.__components) : |
| 75 | return self.__components[i] |
| 76 | else: |
| 77 | raise Exception("index out of range") |
| 78 | def __len__(self): |
| 79 | """ |
| 80 | returns the size of the vector |