Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;constants
- (define background (empty-scene 450 150))
- (define greenf (overlay (circle 65 255 "white") ;зеленый выключен
- (circle 70 255 "green")))
- (define yellowf (overlay (circle 65 255 "white") ;желтый выключен
- (circle 70 255 "yellow")))
- (define redf (overlay (circle 65 255 "white") ;красный выключен
- (circle 70 255 "red")))
- (define red (place-image ;красный включен
- (overlay/offset
- (overlay/offset greenf -145 0 yellowf)
- -217 0 (circle 70 255 "red")) 225 75 background))
- (define yellow (place-image ;желтый включен
- (overlay/offset
- (overlay/offset greenf -145 0
- (circle 70 255 "yellow"))
- -217 0 redf) 225 75 background))
- (define green (place-image ;зеленый включен
- (overlay/offset
- (overlay/offset (circle 70 255 "green")
- -145 0 yellowf)
- -217 0 redf) 225 75 background))
- (define (tl-render x)
- (cond
- [(string=? "green" x) red]
- [(string=? "red" x) yellow]
- [(string=? "yellow" x) green]))
- (define (tl-next x)
- (cond
- [(string=? "green" x) "red"]
- [(string=? "red" x) "yellow"]
- [(string=? "yellow" x) "green"]))
- ;functions
- (define (traffic-light-simulation initial-state)
- (big-bang initial-state
- [to-draw tl-render]
- [on-tick tl-next 1]))
- (traffic-light-simulation "green")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement