이 스키마 코드를 이해할 수 없습니다. Compute-frequencies는 2 개의 분리 된 목록을 찾고자하는 목록과 풀 목록을 취합니다. 찾고있는 목록의 모든 항목이 풀 목록에있는 횟수를 나타내는 목록을 반환해야합니다. 풀리스트를 통해 재귀 호출을 수행 한 후에 가장 큰 오류가 발생할 가능성이 거의 없습니다.스키마 목록 조작
(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 '()))
하위 문제로 분류하면이게 훨씬 쉽습니다. 먼저 목록에서 하나의 항목의 빈도를 계산 한 후 '계산 빈도'에 사용하는 함수를 정의하십시오. 그렇다면 각 함수에서 하나의 목록을 되풀이하는 것에 대해 걱정할 필요가 있습니다. – molbdnilo