Skip to content

Commit

Permalink
rewrite filter_str in functional-style
Browse files Browse the repository at this point in the history
  • Loading branch information
Rudxain authored Mar 14, 2024
1 parent 9b77b9f commit 065b38b
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions src/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,7 @@ 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] == '\\' and s[i + 1] == 'n':
res += '\n'
i += 2
else:
res += s[i]
i += 1
return res
return s[1:-1].replace("\\n", "\n")

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

0 comments on commit 065b38b

Please sign in to comment.