Racket-y, 102

This commit is contained in:
Matthias Felleisen 2014-07-23 11:13:20 -04:00
parent 3849643e4b
commit d321c4e117
2 changed files with 17 additions and 13 deletions

View File

@ -49,21 +49,23 @@
(require 2htdp/universe)
(big-bang 0 (on-tick add1) stop-when))))
;; -----------------------------------------------------------------------------
;; ---------------------------------------------------------------------------------------------------
;; purpose: catch illegal big-bang use w/o world expression
(with-handlers ((exn:fail:syntax?
(lambda (x)
(unless (string=? (exn-message x) "big-bang: expected an initial state, but found a clause")
(raise x)))))
(with-handlers
((exn:fail:syntax?
(lambda (x)
(unless (string=? (exn-message x) "big-bang: expected an initial state, but found a clause")
(raise x)))))
(eval '(module a scheme
(require 2htdp/universe)
(big-bang (on-key add1)))))
(big-bang (on-key add1)))))
(with-handlers ((exn:fail:syntax?
(lambda (x)
(unless (string=? (exn-message x) "universe: expected an initial state, but found a clause")
(raise x)))))
(with-handlers
((exn:fail:syntax?
(lambda (x)
(unless (string=? (exn-message x) "universe: expected an initial state, but found a clause")
(raise x)))))
(eval '(module a scheme
(require 2htdp/universe)
(universe (on-msg sub1) (on-new add1)))))
(universe (on-msg sub1) (on-new add1)))))

View File

@ -16,7 +16,8 @@
(define (w n)
(big-bang 3
[to-draw (lambda (w) (overlay (text (number->string w) 22 'black) (circle 100 'solid 'red)))]
[to-draw (lambda (w)
(overlay (text (number->string w) 22 'black) (circle 100 'solid 'red)))]
[on-tick (lambda (w) (if (<= w 1) (make-package 0 n) (- w 1)))]
[register LOCALHOST]
[port PORT-NO]
@ -46,7 +47,8 @@
(define (w n)
(big-bang 3
[to-draw (lambda (w) (overlay (text (number->string w) 22 'black) (circle 100 'solid 'red)))]
[to-draw (lambda (w)
(overlay (text (number->string w) 22 'black) (circle 100 'solid 'red)))]
[on-tick (lambda (w) (if (= w 1) (make-package 0 n) (- w 1)))]
[register LOCALHOST]
[port PORT-NO]