私は次のように蓄積するための呼び出しに取り組んできました:
(define (accumulate op initial sequence)
(if (null? sequence)
initial
(op (car sequence)
(accumulate op initial (cdr sequence)))))
しかし、フィルターを通して何かを選択して二乗しようとすると、答えは機能しません。私がこれまでに持っているのはこれです:
(define (f2b items)
(accumulate (lambda (x y)
(cons (append
(map square (filter negative? (filter number? x))) x) y)) () items)
)
私が与える入力は次のとおりです。
(f2a '(("sdas" 89) (-53 "sad")))
私が得る出力は次のとおりです。
((sdas 89) (2809 -53 sad))
負の数をなくすことができないようです。