[plt-scheme] Getting started with Scheme: How can I improve my code for generating prime numbers?

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Sun Aug 2 17:37:27 EDT 2009

Before we throw out all solutions, let me add a couple of more  
comments to my original post:

(4 expanded)

5. Since Scheme covers imperative as well as functional programming,  
you can do both -- as Jens and Eli showed in detail and, amazingly,  
you can do both in a reasonably elegant manner, close to what you  
would do in conventional languages. But see (*) below.

Question is what is your goal?
  -- functional programming per se (as a philosopher, I would have to  
question if it exists)
  -- Scheme programming in a functional way?
  -- Scheme programming in the 'best' possible way?
	-- best could mean 'fastest' (as you saw Eli's program is faster  
than yours)
	-- best could mean 'suitable for proving theorems automatically'
	-- and many more things

6. Scheme programming is one thing, PLT Scheme is something  
completely different.

In my mind, PLT Scheme relates to Scheme in the same way that Scheme  
relates to Lisp (its original implementation language) and Algol (one  
of its two influential idea-ancestors, the other one being Actors/ 

As such, PLT Scheme would accommodate an OO solution and a lazy  
functional solution (which I showed you in my message) in addition to  
the above.

Better still, as Eli demonstrated, PLT Scheme comes with the right  
kind of 'syntactic sugar' so that you can program imperatively as if  
you were in a plain imperative language like core Python or C. (*) So  
Eli's program isn't real Scheme at all. It is PLT Scheme, and it  
exploits the features that we added (so-called syntactic extensions,  
unavailable in most other languages) to make Scheme code look concise  
and elegant -- in all aspects.

So the last question is:
  -- perhaps you really want to learn to program in PLT Scheme so  
that you can see what
       elegant lazy functional programmers do,
       strict lazy programmers,
       OO programmers,
       logic programmers,
       and imperative programmers
without ever leaving the language.

I am not sure whether you knew what you were getting into but now you  
have at least the landscape laid out for you -- Matthias

Posted on the users mailing list.