Given:
;;ColorList → ColorList
;; remove green from every color oncl
(define (remove-all-green cl) (cond [(empty? cl) empty] [else (cons (remove-green (first cl)) (remove-all-green (rest cl)))])) ;;Color → Color
;; produce a color likec
, but without any green (define (remove-green c) (make-color (color-red c) 0 (color-blue c))) ;; Tests: (equal? (remove-all-green (cons (make-color 100 100 100) (cons (make-color 200 100 0) empty))) (cons (make-color 100 0 100) (cons (make-color 200 0 0) empty)))
Better:
;;ColorList → ColorList
;; remove green from every color oncl
(define (remove-all-green cl) (local ((define (remove-green c) (make-color (color-red c) 0 (color-blue c)))) (map remove-green cl)))
Best:
;;ColorList → ColorList
;; remove green from every color oncl
(define (remove-all-green cl) (map (lambda (c) (make-color (color-red c) 0 (color-blue c))) cl))