Alkemet News

ryan-duve

2 years ago |

parent
One place I get stuck all the time with Common Lisp is the REPL. I'm used to IPython, which allows me to enter multiple lines and execute them all at once, then go "up" and get all those lines back and change something to fix the error:

    In [1]: my_list = [1, 2, 3]
       ...: my_other_list = [4, 5, 6]
       ...: final_list = [str(i) for i in my_list ++ my_other_list] # whoops a syntax error!
       ...:
       ...: "".join(final_list)
    ---------------------------------------------------------------------------
    TypeError                                 Traceback (most recent call last)
    Cell In[1], line 3
          1 my_list = [1, 2, 3]
          2 my_other_list = [4, 5, 6]
    ----> 3 final_list = [str(i) for i in my_list ++ my_other_list] # whoops a syntax error!
          5 "".join(final_list)

    TypeError: bad operand type for unary +: 'list'

    In [2]: my_list = [1, 2, 3]
       ...: my_other_list = [4, 5, 6]
       ...: final_list = [str(i) for i in my_list + my_other_list]
       ...:
       ...: "".join(final_list)
    Out[2]: '123456'

All the CL REPLs I've tried only allowing getting back one line at a time, which feels tedious to execute in order. I feel like I'm fundamentally missing something about iterative development in Common Lisp and it's blocking me from learning the language.