clean函数用于删除符合条件的list元素,filter函数用于挑选符合条件的list元素
(clean symbol? ‘(1 2 d 4 f g 5 h)) → (1 2 4 5) (filter symbol? ‘(1 2 d 4 f g 5 h)) → (d f g h) (define (big? x) (> x 5)) → (lambda (x) (> x 5)) (clean big? ‘(1 10 3 6 4 5 11)) → (1 3 4 5) (clean <= ‘(3 4 -6 0 2 -3 0)) → (3 4 2) (clean (curry match ‘(a *)) ‘((a 10) (b 5) (a 3) (c 8) (a 9))) → ((b 5) (c 8))
比如下面的代码可以用来将目录下.和..的文件删除掉:
(clean (fn (p) (member p ‘("." ".."))) (directory dir-path))
时间: 2024-10-13 22:49:26