lpython
lpython copied to clipboard
Add support for printing symbolic list
from sympy import pi
from lpython import S
def main0():
l: list[S] = [pi]
print(l)
main0()
(lp) C:\Users\kunni\lpython>src\bin\lpython --enable-symengine try.py
[94581235565888]
Yeah I had given a thought on this, some days back and I think we could surely address this.
The way to do it would be very similar to how list assignment is being resolved through the symbolic ASR pass. So we go from snippet 1 to snippet 2
// snippet 1
l1: list[S] = [x]
// snippet 2
_l1 : list[CPtr] = [x]
l1: List{CPtr] = []
for i in range(len(_l1)):
tmp: CPtr = basic_new_heap()
l1.append(tmp)
basic_assign(l1[i], _l1[i])
This can be addressed similarly
- Create a temporary list for
l
of typelist[Str]
- Use a for loop going over length of
l
- append
basic_str(l1[i])
to temporary list - print(temporary list)