My pleasure.

Good on you for doing the exercise.

Here's a slightly modified version that:

   - removes the use of set!: it's cleaner "functional" style to avoid
   mutation where possible
   - illustrates the use of match-define to unpack world
   - other small tweaks and tricks

Dan


#lang racket

(require 2htdp/universe)
(require 2htdp/image)

(struct world (foreground background count))

(define (random-color)
  (make-color (random 255) (random 255) (random 255)))

(define (next-state state)
  (world (random-color)
         (random-color)
         (add1 (world-count state))))

(define (SUPER state)
  (match-define (world fg bg n) state)
  (overlay/align 'left 'top
                 (text (~a n) 30 "gray")
                 (overlay (text "SUPER" 105 fg)
                          (circle 200 "solid" bg))))

(big-bang (world (random-color) (random-color) 0)
          (on-tick next-state 0.3)
          (to-draw SUPER))

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to