Contents

On Learning Scheme

History

What version of Scheme we use

As there are many versions of Scheme, we need to choose some specific of them. We are going to use TinyScheme-R7 - it is a small interpreter written in a single C file, so we easily prepare versions to run in Windows, in browser, on server etc. Everyone could grab it and compile for mor special platform (e.g. Linux, OS X, BSD).

There are some disadvantages - like pool error handling etc - but we can improve this by and by since it is our own version, derived from original TinyScheme - thing which was used in GIMP image editor.

Main improvements in TinyScheme-R7 are some features from newer R7RS standard, some bugfixes and few features to tailor it specifically for our needs.

How to use it

  1. If you look at the TinyScheme-R7 web-page (mentioned above), you may find in-browser emulator, it allows easy sandbox for trying language functions, testing your small programs etc.
  2. Also here is Downloads link - for Windows you should be able to get archive containing scheme.exe - ready executable.
  3. For other platforms it should be easy to build executable by running make on content of the archive.

Where to get tutorials, manuals etc

We don't have yet docs and tutorials for our TinyScheme-R7 specifically, so you may use any Scheme tutorial or manual you like (verifying your code with emulator or running it locally).

Recommended resources are:

Note on performance

Interpreted languages are not that fast as compiled. Python code, for example, may be 20 times slower than similar program in C. It is similar in our case. As the server can't hang too long when running your solution, it has some internal restriction on number of steps executed - currently, 3 mln. These steps are calls of Scheme expressions, e.g. here are 4 calls:

(* 5 3)

Two calls for every argument, one for function name (yes, "*") and one call for function calculation itself.

When testing, you can call (eval-count) function (non-standard of course) to check this counter and make some conclusions.

IF YOUR SOLUTION DOESN'T WORK

There could be various reasons of failure. Try to analyze what is happening.

  1. If checker says there is error on calling interpreter (and persists despite of retrying) - probably it is a bug which should be reported.
  2. If there is error on execution - probably there is something critically bad with your code (unknown functions, missing brackets etc).
    • in such case it may help to temporarily reduce parts of your code (i.e. replace them with some dummy return values etc) to see which part causes issue.
  3. If checker complains about line number in output - probably code is printing when it shouldn't or vice versa, not printing when should.

Try to get some sense from "verdict" given by checker. Check your code with emulator (or better with interpreter downloaded to your machine) - remember other versions of Scheme may behave differently from one used by the checker.

Feel free to complain at forum - since functionality is new, it may be buggy. Tell if you have difficulties with emulator or local interpreter - perhaps we can improve it.