Scheme好像没有内置过滤器filter
lisp吧
全部回复
仅看楼主
level 10
ljqican 楼主
也可能是我眼花,在r5rs中看漏了,自己写个
(define (filter f ls)
__(if (null? ls)
______'()
______(if (f (car ls))
__________(cons (car ls)
__________________(filter f (cdr ls)))
________________(filter f (cdr ls)))))
测试
> (filter (lambda (x) (< x 3)) '(1 2 3 4 5))
(1 2)
2012年10月25日 03点10分 1
level 6
r6rs里有filter,其实用 map 也差不多
2012年10月25日 04点10分 2
怎么用map?不会唉
2012年10月25日 05点10分
回复 ljqican :map好像一定要返回一个值
2012年10月25日 05点10分
回复 ljqican :[汗] 真的诶。
2012年10月25日 07点10分
回复 狂人fantasy :所以说map就不能代替filter啊
2012年10月25日 08点10分
1