;; The first three lines of this file were inserted by DrScheme. They record metadata ;; about the language level of this file in a form that our tools can easily process. #reader(lib "htdp-advanced-reader.ss" "lang")((modname |36.4|) (read-case-sensitive #t) (teachpacks ((lib "draw.ss" "teachpack" "htdp") (lib "arrow.ss" "teachpack" "htdp") (lib "gui.ss" "teachpack" "htdp"))) (htdp-settings #(#t constructor repeating-decimal #t #t none #f ((lib "draw.ss" "teachpack" "htdp") (lib "arrow.ss" "teachpack" "htdp") (lib "gui.ss" "teachpack" "htdp"))))) ;A traffic-light color (TL-color) is either ;1. 'red, ;2. 'yellow, or ;3. 'green. ;;State Variable: ;;current-color : TL-color (define current-color 'red) ;next : -> void ;Effect: Changes current-color from 'red to 'green, 'green to 'yellow, or 'yellow to 'red depending on what the current-color is. Produces no output. (define (next) (set! (next-color current-color))) ;next-color : TL-color -> TL-color ;Given acolor, returns the next logical color. (define (next-color acolor) (cond [(symbol=? acolor 'red) 'green] [(symbol=? acolor 'yellow) 'red] [(symbol=? acolor 'green) 'yellow]))