リストのリストをトラバースするソリューションは、ソリューションのよく知られたテンプレートに従います。一般的な構造を示しますので、空欄を埋めることができます。自分でソリューションを見つけた方がはるかに優れています。意味!
(define (remove-strings lst)
(cond (<???> <???>) ; if the list is empty, return the empty list
((not (pair? <???>)) ; if the current element is not a list
(if (string? <???>) ; if the current element is a string
(remove-strings <???>) ; simply advance recursion over cdr (*)
(cons <???> ; else keep the current element
(remove-strings <???>)))) ; advance recursion over cdr
(else ; otherwise it's a list of lists
(cons (remove-strings <???>) ; advance recursion over car
(remove-strings <???>))))) ; advance recursion over cdr
(*)
では、新しいリストを作成する過程で見つけたすべての文字列を単純に無視して「削除」していることに注意してください。次の行では、文字列でない場合は、出力リストを作成する間、要素を保持します。上記は、任意にネストされたリストに対して機能します。