@@ -94,7 +94,55 @@ func (l *List) M__setitem__(key, value Object) Object {
94
94
return None
95
95
}
96
96
97
+ func (a * List ) M__add__ (other Object ) Object {
98
+ if b , ok := other .(* List ); ok {
99
+ newList := NewListSized (len (a .Items ) + len (b .Items ))
100
+ copy (newList .Items , a .Items )
101
+ copy (newList .Items [len (b .Items ):], b .Items )
102
+ return newList
103
+ }
104
+ return NotImplemented
105
+ }
106
+
107
+ func (a * List ) M__radd__ (other Object ) Object {
108
+ if b , ok := other .(* List ); ok {
109
+ return b .M__add__ (a )
110
+ }
111
+ return NotImplemented
112
+ }
113
+
114
+ func (a * List ) M__iadd__ (other Object ) Object {
115
+ if b , ok := other .(* List ); ok {
116
+ a .Extend (b .Items )
117
+ return a
118
+ }
119
+ return NotImplemented
120
+ }
121
+
122
+ func (l * List ) M__mul__ (other Object ) Object {
123
+ if b , ok := convertToInt (other ); ok {
124
+ m := len (l .Items )
125
+ n := int (b ) * m
126
+ newList := NewListSized (n )
127
+ for i := 0 ; i < n ; i += m {
128
+ copy (newList .Items [i :i + m ], l .Items )
129
+ }
130
+ return newList
131
+ }
132
+ return NotImplemented
133
+ }
134
+
135
+ func (a * List ) M__rmul__ (other Object ) Object {
136
+ return a .M__mul__ (other )
137
+ }
138
+
139
+ func (a * List ) M__imul__ (other Object ) Object {
140
+ return a .M__mul__ (other )
141
+ }
142
+
97
143
// Check interface is satisfied
144
+ var _ sequenceArithmetic = (* List )(nil )
145
+ var _ I__len__ = (* List )(nil )
98
146
var _ I__len__ = (* List )(nil )
99
147
var _ I__bool__ = (* List )(nil )
100
148
var _ I__iter__ = (* List )(nil )
0 commit comments