(define (delete atm lis)
(cond
((eq? atm (car lis)) (cdr lis))
(else (cons (car lis) (delete atm (cdr lis))))))
(delete 'a '(b c d a))
(delete 'the '(the more you practice the better you will be))
(delete 'cat '((dog cat) mouse cat (elephant) (cat) cat))
(delete 'rainy '(the weather can be (rainy) sunny cloudy and cold))
我想输出是Scheme如何从列表中删除元素?
- (BCD)
- (你练习得越多就越会是)
- ((狗猫)鼠标(大象)(CAT))
- (气候可能(雨天)晴天阴天和冷)
但有很多错误,请帮助我,谢谢
但是如果我想找到的原子不是列表中的第一个元素,它仍然有错误。你能告诉我为什么吗? – Lilo 2010-12-15 15:33:43
@Lilo:你最好告诉我们什么是“错误的”,因为leppie的答案是正确的。 – erjiang 2010-12-16 02:25:28