#| A PR record is - (define-struct PR (name exchange profit)) A list-of-PRs is either - empty - (cons p lor) where p is a PR record and lor is a list-of-PRs. (define (LOPR-template alopr) (cond [(empty? alopr) ...] [else ... (first alopr) ... (LOPR-template (rest alopr)) ...])) ;; ^^^ a PR-record ^^^ possible natural recursion |# ;; project : list-of-PRs -> list-of-symbols ;; return the names of all PR records with profit between 10 and 20 (incl) (define (project alopr) (names (okay-prs alopr))) ;; names : list-of-PRS -> list-of-symbols ;; return the names of all the PR records (define (names alopr) (cond [(empty? alopr) empty] [else (cons (PR-name (first alopr)) (names (rest alopr)))])) ;; okay-prs : list-of-PRs -> list-of-PRs ;; return all PR records with profit between 10 and 20 (incl) (define (okay-prs alopr) (cond [(empty? alopr) empty] [else (cond [(okay? (first alopr)) (cons (first alopr) (okay-prs (rest alopr)))] [else (okay-prs (rest alopr))])])) ;; okay? : PR -> boolean ;; determine whether a-PR's profit is between 10 and 20 (incl) (define (okay? a-PR) (<= 10 (PR-profit a-PR) 20))