[BULK] [plt-scheme] Teaching Scheme

From: Stephen Bloch (sbloch at adelphi.edu)
Date: Mon May 3 09:01:25 EDT 2010

On May 3, 2010, at 8:17 AM, Samuel Williams wrote:

> I'm putting together a website aimed at high school students and teachers, and would like to make sure the following page is as good as possible:
> 
> 	http://programming.dojo.net.nz/languages/scheme/index
> 
> In particular, "Why would I learn this language?" section needs to have a few paragraphs. I don't use Scheme so I hoped that you could provide the main reasons why Scheme is a language someone would want to learn about.

Take a look at http://www.adelphi.edu/sbloch/class/tsrj/testimonials/ .

> It would also be great if someone could rewrite the Scheme source code example so that it is as close as possible to the C implementation:
> 
> 	http://programming.dojo.net.nz/languages/c/index
> 
> I understand that Scheme is very different from C, and uses different paradigms, so it doesn't have to be identical, however it would be great if it worked in generally the same way. It would be great if you could include comments explaining how it works and what is happening (like the C example).

Well, that particular algorithm relies very heavily on mutation, but here's a functional version.

(define (door-open door)
  (doh door 99))

(define (doh door pass)
  (cond [(zero? pass) true]
        [(= (remainder door (+ pass 1)) pass)
         (not (doh door (- pass 1)))]
        [else
         (doh door (- pass 1))]))

(define doors (build-list 100 door-open))



Somewhat shorter but more cryptic:

(define (door-open door)
  (doh door 99))

(define (doh door pass)
  (or (zero? pass)
      (not (boolean=? (= (remainder door (+ pass 1)) pass)
                      (doh door (- pass 1))))))

(define doors (build-list 100 door-open))



Even shorter, but takes some math (and illustrates how artificial this problem is :-) :

(define (door-open door)
   (integer? (sqrt (+ door 1))))

(define doors (build-list 100 door-open))



Stephen Bloch
sbloch at adelphi.edu



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20100503/d02eb9da/attachment.html>

Posted on the users mailing list.