Remove integers from list

匆匆过客 提交于 2020-01-03 04:25:14

问题


I have a strange problem that couple of hours can't implement in Scheme. Let's say we have:

(define x '( (Orlando (NY 3))
             (Chicago (Montana 5) (Orlando 8))
             ...and so on ...
           )

I want to transform it to

'( (Orlando NY)
   (Chicago Montana Orlando)
    ...and so on ...
 )

Any help would be greatly appreciated.


回答1:


You could also try

(map 
 (lambda (x) (cons (car x) (map car (cdr x)))) 
 x)


来源:https://stackoverflow.com/questions/20749277/remove-integers-from-list

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!