リストから要素を「削除する」ことを「選択する」と言う場合、任意にネストされたリストのリストに対して次のように行い、空白を埋めます。
(define (pick7 x)
(cond (<???> <???>) ; if the list is null, return null
((not (pair? <???>)) ; if the first element is not a list
(if <???> ; if the first element is 7
(pick7 <???>) ; advance recursion over rest of list
(cons <???> ; else cons the first element and
(pick7 <???>)))) ; advance recursion over rest of list
(else (cons ; if the first element is a list, then cons
(pick7 <???>) ; the recursion over the first element
(pick7 <???>))))) ; and the recursion over the rest of list
これは、任意にネストされたリストのリストを処理するための標準テンプレートであることに注意してください。これは、次のような場合に機能します。
(pick7 '(1 3 (5 7 (8 7 (10 7 11))) 9 7))
=> '(1 3 (5 (8 (10 11))) 9)