Replace elements in nested quoted lists adds new elements?

前端 未结 3 923
遇见更好的自我
遇见更好的自我 2020-12-22 09:48

I have a nested list, and I am trying to non-destructively replace all its elements (inside the nested list as well). That is, given my input list

\'(1 \'(2         


        
3条回答
  •  臣服心动
    2020-12-22 10:26

    What am I doing wrong?

    You have actually done a good work with loop and it works! Remember that ' stands for quote, so:

    '(1 '(2 3 4) '(5 6 7) 8 9)
    

    is equal to

    (quote (1 (quote (2 3 4)) (quote (5 6 7)) 8 9))
    ;       |  |      | | |    |      | | |   | |
           (0 (0     (0 0 0)) (0     (0 0 0)) 0 0)
    

    you see, your quotes have been substituted too (except for the first one, which has been consumed during evaluation of the function argument)! One quote is enough to suspend execution.

提交回复
热议问题