Closed johnynek closed 5 days ago
with this we get
def string_to_Char(s: String) -> Option[Char]:
match s:
case "$.{c}": Some(c)
case _: None
compiling to:
def string_to_Char(s):
if s.__len__() == 1:
return (1, s[0])
else:
return (0,)
and
def last_String(s: String) -> Option[Char]:
match s:
case "": None
case "${_}$.{l}": Some(l)
compiling to:
def last_String(s):
if s == "":
return (0,)
else:
return (1, s[-1])
Even though C backend is the priority, by improving python code-gen we learn about how to make codegen in general better.
This also improves the python code generation somewhat after looking more at the generated code.