How to Reverse a List?

前端 未结 7 2196
有刺的猬
有刺的猬 2020-12-03 06:28

What is the function to a list in Scheme? It needs to be able to handle nested lists.

So that if you do something like (reverse \'(a (b c d) e)) you\'ll

7条回答
  •  醉话见心
    2020-12-03 06:41

    You could simply reverse the elements in a list using foldr:

    (foldr (lambda (a r) (append r (list a))) empty lst)
    

提交回复
热议问题