def multed_by(self, other): if isinstance(other, List): new_list = self.copy() new_list.elements.extend(other.elements) return new_list, None else: return None, Value.illegal_operation(self, other)
def get_comparison_gte(self, other): if isinstance(other, Number): return ( Number(int(self.value >= other.value)).set_context( self.context), None, ) else: return None, Value.illegal_operation(self, other)
def ored_by(self, other): if isinstance(other, Number): return ( Number(int(self.value or other.value)).set_context(self.context), None, ) else: return None, Value.illegal_operation(self, other)
def dived_by(self, other): if isinstance(other, Number): if other.value == 0: return None, RTError(other.pos_start, other.pos_end, "Division by zero", self.context) return Number(self.value / other.value).set_context( self.context), None else: return None, Value.illegal_operation(self, other)
def dived_by(self, other): if isinstance(other, Number): try: return self.elements[other.value], None except: return None, RTError( other.pos_start, other.pos_end, "Element at this index could not be retrieved from list because index is out of bounds", self.context, ) else: return None, Value.illegal_operation(self, other)
def subbed_by(self, other): if isinstance(other, Number): new_list = self.copy() try: new_list.elements.pop(other.value) return new_list, None except: return None, RTError( other.pos_start, other.pos_end, "Element at this index could not be removed from list because index is out of bounds", self.context, ) else: return None, Value.illegal_operation(self, other)
def added_to(self, other): if isinstance(other, String): return String(self.value + other.value).set_context( self.context), None else: return None, Value.illegal_operation(self, other)
def multed_by(self, other): if isinstance(other, Number): return String(self.value * other.value).set_context( self.context), None else: return None, Value.illegal_operation(self, other)
def subbed_by(self, other): if isinstance(other, Number): return Number(self.value - other.value).set_context( self.context), None else: return None, Value.illegal_operation(self, other)