Skip to content

Commit

Permalink
fix "\n" conversion in helpers.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Rudxain authored Mar 14, 2024
1 parent 45f7bdf commit 9b77b9f
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,21 @@ def remove_all(l: list, x):
return l

def filter_str(s:str):
"""
Remove 1st and last chars, and
replace line-feed literals with actual line-feeds.
"""
res = ""
i = 1
while i < len(s) - 1:
if s[i] == '\\':
if s[i + 1] == 'n':
res += '\n'
i += 1
if s[i] == '\\' and s[i + 1] == 'n':
res += '\n'
i += 2
else:
res += s[i]
i += 1
return res

# filter_str: Final[Callable[[str], str]] = lambda s: s[1:-1]
"""Remove 1st and last chars from a `str`."""


def precedence(op: str):
"""
Get precedence of basic arithmetic operators (+ - * /).
Expand Down

0 comments on commit 9b77b9f

Please sign in to comment.