Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix "\n" conversion in filter_str #73

Merged
merged 2 commits into from
Mar 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 5 additions & 15 deletions src/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,11 @@ def remove_all(l: list, x):
return l

def filter_str(s:str):
res = ""
i = 1
while i < len(s) - 1:
if s[i] == '\\':
if s[i + 1] == 'n':
res += '\n'
i += 1
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`."""

"""
Remove 1st and last chars, and
replace line-feed literals with actual line-feeds.
"""
return s[1:-1].replace("\\n", "\n")

def precedence(op: str):
"""
Expand Down
Loading