Shift methods updated.

This commit is contained in:
Rhinemann 2023-06-18 14:51:13 +03:00
parent 5fece34356
commit 9f12616eca
1 changed files with 4 additions and 4 deletions

View File

@ -11,14 +11,14 @@ class BasicRegister:
def reverse(self):
self.memory = [not value for value in self.memory]
def left_shift(self, steps_shifted: int) -> list[bool]:
self.memory.extend([False] * steps_shifted)
def left_shift(self, digit_to_fill: bool = False, steps_shifted: int = 1) -> list[bool]:
self.memory.extend([digit_to_fill] * steps_shifted)
shifted_radices: list[bool] = self.memory[:steps_shifted]
del self.memory[:steps_shifted]
return shifted_radices
def right_shift(self, steps_shifted: int) -> list[bool]:
self.memory[:0] = [False] * steps_shifted
def right_shift(self, digit_to_fill: bool = False, steps_shifted: int = 1) -> list[bool]:
self.memory[:0] = [digit_to_fill] * steps_shifted
shifted_radices: list[bool] = self.memory[-steps_shifted:]
del self.memory[-steps_shifted:]
return shifted_radices