Introduction to Scheme I:
The Scheme Homepage
The R4RS Scheme Manual
Overview
Jscheme
is a dialect of the
Scheme programming language
which has been
implemented in
Java
The principle benefits of Jscheme, as compared to other computer
languages are:
- Jscheme is a dialect of Scheme.
Jscheme is a powerful language but is
simple enough that one can easily learn the core language in a few days.
- Jscheme is an interpreted language implemented in Java.
This allows one to write, debug, and run Scheme programs
directly from an off-the-shelf web browser.
There is no need to download and install any special software. If however
you have Java 1.2 installed, you can use Jscheme to implement standalone
applications and servlets, as well as applets.
- Jscheme has a simple and complete interface to the extensive Java libraries
This allows interactive interaction with the libraries as we will see
in the first example below.
You can test out these claims by cutting and pasting the examples
below into the green interpreter applet window and pressing the
eval button.
The Scheme Interpreter Applet
Assuming you have a browser that is Java 1.1 enabled,
the Jscheme interpreter applet will appear below. It may take
several minutes to load up if you are loading this page over a slow modem.
This applet allows one to enter and run Jscheme programs like the
following Hello World demo, which you should cut and paste into
the interpreter window.
;; cut and paste into interpreter window and press "eval"
(define win
(window "Hello.silk"
(label "HELLO WORLD!" red (CourierBold 60))))
(.pack win)
(.show win)
|
When this program is evaluated (by pushing the eval button), the Scheme interpreter
creates a window with the phrase "Hellow.silk" in the title
bar, and it puts a big red box with the words "HELLO WORLD!" into the demo window itself
using a 60 point boldface Courier font.
You can then modify
the program, say by changing the title to "Second Example" and the label to "Konichi-wa".
When you press the eval button a new window will pop up with the specified changes.
Below are a few more examples you can try.
(.setBackground thisContainer (color 120 170 120))
|
;; fibonacci: cut and paste into interpreter window
;; and press the "eval" button.
(define (fib n)
(if (< n 3) 1
(+ (fib (- n 1)) (fib (- n 2))))))
(fib 15)
(time (fib 15) 1) ;; this calls (fib 15) once and returns the runtime
|