¤ Design bad-cards. The function consumes a list of cards and a date (number); it extracts all those cards whose dates occur before the given date. Start with the data definition. You may use local if an expression might be computed twice.
;; [1pt for data definition of LOCT] ;; LOCT is one of: ;; -- empty ;; -- (cons CT LOCT) ;; [1pt for correct contract and purpose] ;; bad-cards : LOCT Number -> LOCT ;; extract all those cards whose dop is before dt (define (bad-cards l dt) (cond [(empty? l) empty] ;; [2 pt for correct local definitions: fst and rst] [else (local ((define fst (first l)) (define rst (bad-cards (rest l) dt))) (cond ;; [1pt for correctness] [(< (card-dop fst) dt) (cons fst rst)] [else rst]))])) ;; Alternately done with FILTER [3 points] (define (bad-cards l dt) (filter (lambda (ct) (< (card-dop ct) dt)) l))