def slice(self, start: int, length: int, span: Span) -> 'Array': if start + length > len(self.elements): raise errors.FailureError( span=span, message= 'Start {} with length {} out of bounds of array length {}.'. format(start, length, len(self.elements))) return Array(tuple(self.elements[start:start + length]))
def update(self, i: int, v: Value, span: Span) -> 'Array': if i >= len(self.elements): raise errors.FailureError( span=span, message='Index {} out of bounds of array length {}.'.format( i, len(self.elements))) return Array( tuple(v if i == j else e for j, e in enumerate(self.elements)))