从列表中删除整数 [英] Remove integers from list

查看:92
本文介绍了从列表中删除整数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个奇怪的问题,几个小时无法在Scheme中实现. 假设我们有:

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 ...
           )

我想将其转换为

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

任何帮助将不胜感激.

推荐答案

您也可以尝试

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

这篇关于从列表中删除整数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆