過濾

filter 返回給定列表中每個專案的列表,給定謂詞返回非 #f 值。

;; Get only even numbers in a list
> (filter even? '(1 2 3 4))
'(2 4)

;; Get all square numbers from 1 to 100
> (filter (lambda (n) (integer? (sqrt n))) (range 1 100))
'(1 4 9 16 25 36 49 64 81)