[plt-dev] Racket web page

From: engineer at alum.mit.edu (engineer at alum.mit.edu)
Date: Wed May 26 10:35:06 EDT 2010

I think the time func is a useful tool to show off.

Maybe use the time func to compare 2 sort algos?
Or to show that a particular algorithm is order n-squared or log-n...

Below are a couple of attempts I made at some small interactive programs.
Unfortunately, squeezing them down really began to obfuscate things, but I
figured I ought to forward them along.  Maybe someone here will like one and
be able to shrink it further or clarify it.

A scribbler:
#lang scheme
(require 2htdp/universe)
(require 2htdp/image)
(define (mouser state x y e)
  (list (if (and (> (length state) 1) (string=? e "drag"))
            (add-line (first state) (second state) (third state) x y "red")
            (first state))
        x y))
(big-bang (list (empty-scene 300 300)) (on-mouse mouser) (on-draw first))


A discretized scribbler:
;; #lang BSL somehow
(require 2htdp/universe)
(require 2htdp/image)
(define (handler dots x y event)
  (if (member event (list "drag" "button-down"))
      (place-image (circle 1 "solid" "red") x y dots) dots))
(big-bang (empty-scene 99 99) (on-mouse handler) (on-draw identity))

I suppose a mouse tracker would save a line, but drag is demonstrative.

Mouse/key interaction, begging for abstraction.  Perhaps keyboard and mouse
functionality could be showcased separately to a better effect
;; in BSL
(require 2htdp/universe)
(require 2htdp/image)
(define (mh s x y me) (text (format "(~a,~a) ~a" x y me) 12 "red"))
(define (kh s ke) (text (format "~a pressed " ke) 12 "red"))
(define (rh s re) (text (format "~a released " re) 12 "red"))
(big-bang (empty-scene 300 50) (on-mouse mh) (on-key kh) (on-release rh)
(on-draw identity))


Sorta pendulum
#lang scheme
(require 2htdp/universe)
(require 2htdp/image)
(define (render t)
  (rotate (* 90 (cos (* t .06)))
          (overlay/xy (circle 15 "solid" "red")
                      -85 -170 (circle 100 "solid" "blue"))))
(big-bang 1 (on-tick add1) (on-draw render))


Simple rocket blasting off to fight gravity
#lang scheme
(require 2htdp/universe)
(require 2htdp/image)
(define (gravity ws) (list (+ (car ws) (cadr ws)) (+ (cadr ws) 0.1)))
(define (render ws) (place-image (triangle 8 "solid" "red") 50 (car ws)
(empty-scene 99 500)))
(define (blast ws z) (list (car ws) (- (cadr ws) 1)))
(big-bang (list 50 0) (on-tick gravity) (on-draw render) (on-key blast))


-Paul


> -----Original Message-----
> From: robby.findler at gmail.com [mailto:robby.findler at gmail.com] On Behalf
> Of Robby Findler
> Sent: Saturday, May 22, 2010 10:23 PM
> To: engineer at alum.mit.edu
> Cc: plt-dev at list.cs.brown.edu
> Subject: Re: [plt-dev] Racket web page
> 
> That one's just 'sort' so it feels kind of short. But things like that
> that aren't in the stdlib are definitely good!
> 
> Robby
> 
> On Sat, May 22, 2010 at 9:04 PM,  <engineer at alum.mit.edu> wrote:
> >
> > What about a "sort a list," or is that too academic?
> >
> >> -----Original Message-----
> >> From: plt-dev-bounces at list.cs.brown.edu [mailto:plt-dev-
> >> bounces at list.cs.brown.edu] On Behalf Of Matthew Flatt
> >> Sent: Saturday, May 22, 2010 12:55 PM
> >> To: plt-dev at list.cs.brown.edu
> >> Subject: Re: [plt-dev] Racket web page
> >>
> >> Thanks for all the feedback! See below for a status update, and take a
> >> quick look at the revised page:
> >>
> >>  http://www.cs.utah.edu/~mflatt/tmp/r/www/
> >>
> >>
> >> I'm disappointed that we're getting so few 7-line program suggestions.
> >> Please suggest more.
> >>
> >> The main guideline for a good example is that it should demonstrate
> >> something that a programmer already wants to do. While I appreciate
> >> Guillaume's suggestion, I don't think that "use functional hash tables"
> >> is on many wish lists. In contrast, I think of "traverse a directory
> >> tree", "create a web server", "create a GUI", and "produce documents"
> >> as more concrete tasks that are easier for programmers to appreciate.
> >>
> >> That's just a guideline, and the "write static types" and "handle
> >> infinite lists" examples are a bit indirect by that standard --- but
> >> they're also language details that certain communities latch onto,
> >> which is why think those work anyway.
> >>
> >> In any case, we need more good examples, and we especially need easy
> >> examples like the first few.
> >>
> >> ----------------------------------------
> >>
> >> Things fixed:
> >>
> >>  * The bad intro text at the top left has been removed.
> >>
> >>  * The Javascript bug that caused clicking the arrows to scroll
> >>    the page is now fixed.
> >>
> >>  * The code is colorized and hyperlinked.
> >>
> >>  * The initial example is likely to be simpler, since only the first
> >>    three are candidates to the initial example. (The examples are
> >>    always in the same order; only the starting position changes.)
> >>
> >>  * The "?" panel explains the current example.
> >>
> >>  * "Grow your Mind" => "Grow your Skills"
> >>
> >> Things not yet fixed:
> >>
> >>  * We don't yet have good intro text for the top left.
> >>
> >>  * The links still mostly go to documentation. (Unfortunately, I don't
> >>    see that changing before the release.)
> >>
> >>  * Some text changes are still needed on pages other the front page.
> >>
> >> The were also some style suggestions that we'll consider further,
> >> including an auto-advance for the slideshow.
> >>
> >> _________________________________________________
> >>   For list-related administrative tasks:
> >>   http://list.cs.brown.edu/mailman/listinfo/plt-dev
> >
> > _________________________________________________
> >  For list-related administrative tasks:
> >  http://list.cs.brown.edu/mailman/listinfo/plt-dev
> >



Posted on the dev mailing list.