got distracted and made a repl framework.......

This commit is contained in:
Emile Clark-Boman 2025-06-22 00:26:54 +10:00
parent 0a2d9a5694
commit c18aa29c58
5 changed files with 227 additions and 17 deletions

View file

@ -15,3 +15,14 @@ Left pad an integer's binary representation with zeros
def lpadbin(x: int, n: int) -> str:
return lpad(bin(x)[2:], n, pad='0')
'''
Extends the standard lstrip string method,
allowing the max: int kwarg to be supplied.
'''
def lstrip(s: str, prefix: str, max: int = -1) -> str:
l = len(prefix)
c = 0
while s.startswith(prefix) and c < max:
s = s[l:]
c += 1
return s