[plt-dev] Racket web page

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Tue May 25 23:00:17 EDT 2010

At Tue, 25 May 2010 22:39:34 -0400, Carl Eastlund wrote:
> #lang racket
> ;; A dice-rolling command-line utility
> (require racket/cmdline)
> (command-line
>  #:args (dice sides)
>  (for ([i (in-range (string->number dice))])
>    (displayln (+ 1 (random (string->number sides))))))
> 
> This version puts "dice" and "sides" in the more canonical order, for
> those of us used to writing both down consistently.  I also fixed your
> off-by-one error in calling "random".

Thanks!
> No one appears to have big-bang so far, so here's the best I can come
> up with in 7 lines:
> 
> #lang htdp/bsl
> (require 2htdp/image) (require 2htdp/universe)
> ;; Blow up a big red balloon before it deflates.
> (define (balloon b) (circle b "solid" "red"))
> (define (blow-up b k) (+ b 5))
> (define (deflate b) (max (- b 1) 1))
> (big-bang 50 (on-key blow-up) (on-tick deflate) (to-draw balloon 200 200))

There was one before, but this one fits the current set better. Thanks!



Posted on the dev mailing list.