a tail-recursion version list appending function

后端 未结 5 2143
猫巷女王i
猫巷女王i 2020-12-04 01:44

i see several examples of implementing append an element to a list, but all are not using tail recursion. how to implement such a function in a

5条回答
  •  伪装坚强ぢ
    2020-12-04 02:17

    You can't naively, but see also implementations that provide TCMC - Tail Call Modulo Cons. That allows

    (cons head TAIL-EXPR)
    

    to tail-call TAIL-EXPR if the cons itself is a tail-call.

提交回复
热议问题