Next: Introduction, Up: (dir) [Contents][Index]
• Introduction: | Introduction to Scheme and s2scm. | |
• Installation: | How to install s2scm. | |
• Getting started with s2scm: | How to compile Scheme programs. | |
• Index: | Index. |
Next: Installation, Previous: Top, Up: Top [Contents][Index]
Scheme is a multi-paradigm computer programming language that is a dialect of John McCarthy’s LISP programming language.
LISP is notable for supporting the functional programming paradigm, where side-effects are avoided, and for its straightforward ‘S-Expression’ syntax.
This manual assumes basic knowledge of the Scheme programming language. To learn Scheme, you can read the book Structure and Interpretation of Computer Programs.
Scratch is MIT’s educational programming language, targeted primarily at children. It’s very easy to get started with.
You can find Scratch at http://scratch.mit.edu/.
s2scm is a compiler for Scheme that outputs projects for Scratch.
s2scm is written in the Python programming language, and uses the kurt library by blob8108 to output Scratch projects.
Next: Getting started with s2scm, Previous: Introduction, Up: Top [Contents][Index]
To install s2scm, you should have Python 2.7 installed, and the pip
or easy_install
programs.
Computers running Apple OS X have Python and easy_install
pre-installed.
If you have administrative previliges, you may simply open up the Terminal and enter the following:
sudo easy_install s2scm
Press the return key after typing the command in.
This will download and install s2scm and all its dependencies.
Microsoft Windows does not ship with Python. If you have not previously installed it, you will need to install it now.
Download and install Python 2 from https://www.python.org/. Python versions more than 2.7.9 come with pip
, so you will not need to install it seperately.
Now open a Command Prompt and run the command:
pip install s2scm
Press the Return or Enter key after typing the command in.
This will download and install s2scm and all its dependencies.
Many GNU/Linux distributions come with Python and pip pre-installed.
If you don’t have Python and pip installed, you’ll need to install it. The way you do this depends on your distribution.
Assuming you have Python and pip installed, you’ll need to run the following command as the superuser:
pip install s2scm
Next: Index, Previous: Installation, Up: Top [Contents][Index]
Here is some example source code you can save in a file:
(say "Hello world!" (+ 1 (* 2 2)))
Save it as plain text in the file hello.scm
.
Open a command prompt and change to the directory where you saved the file. This can be done with the cd
command on Windows, OS X and GNU/Linux, as well as most flavours of UNIX.
Then, run the following command to compile:
python -m s2scm hello.scm hello.sb2
This will output a Scratch project to hello.sb2
.
If you, for example, didn’t want to compile hello.scm
but example.scm
, you would change the command to:
python -m s2scm example.scm hello.sb2
You can do the same thing for the output file.
Now you can open the Scratch editor, click on the File menu, click “Upload from your computer”, and choose the compiled project. It should also work with the Scratch 2.0 offline editor.
The say
function is s2scm-specific. It takes two arguments, a string for the Scratch sprite to say, and the duration for how long it will be said.
It corresponds to the Scratch ‘say () for () secs’ blocks.
The +
function adds numbers together, and appears in standard Scheme.
Previous: Getting started with s2scm, Up: Top [Contents][Index]
Jump to: | B I K P S W |
---|
Jump to: | B I K P S W |
---|