我无法弄清楚这个方案代码请帮忙。Compute-frequencies 包含两个独立的列表,查找列表和池列表。它应该返回一个列表,显示查找列表中的所有内容在池列表中的次数。我知道我很接近它只是一些小错误,很可能与通过池列表后的递归调用有关。
(define (compute-frequencies looking-for-list pool-list)
(define (helper looking-for-list pool-list current-frequency frequency-list) ; keeps track of finished list and iterates through both lists
(if (null? looking-for-list) (reverse frequency-list) ; finding the number of times data in looking-for-list are in pool-list
(if (null? pool-list)
(helper (cdr looking-for-list) pool-list 0 (cons current-frequency frequency-list))
(if (equal? (car looking-for-list) (car pool-list))
(helper looking-for-list (cdr pool-list) (+ 1 current-frequency) frequency-list)
(helper looking-for-list (cdr pool-list) current-frequency frequency-list)))))
(helper looking-for-list pool-list 0 '() ))