Saliya's Blogs

Mostly technical stuff with some interesting moments of life

Showing posts with label scheme. Show all posts
Showing posts with label scheme. Show all posts

Record Scheme Sessions: Transcript

Ever wanted to save what you type in your Scheme interpreter? I wanted :). So after a small Google search I found these nice two commands.

To start recording type,
(transcript-on "filename")

To end recording type,
(transcript off)

That's it. Now your session is saved in the file given by you.

Scheme Way: Eclipse Plug-in

I thought of searching for an IDE for Scheme, after being bit lazy to learn Emacs. Lucky enough I found a nice plugin for Eclipse named SchemeWay. It took me a bit of time, however, to configure and set up the plug-in to work as I like.

If you are struggling to set it up (as I did) here are few steps to help you with.

1. Download Eclipse from http://www.eclipse.org/downloads/. I chose the classic version

2. Download SchemeWay update pack from

3. Unpack the UpdateSite-1.3.0.alpha7.zip and copy the stuff inside plugins and features folders to eclipse features and plugins folders.

4. Start Eclipse and go to Help --> Install New Software.

5. Click Add on the on the Install window you get. It will give you a small window with two text boxes.

6. Click Local next to the Name text box. Now you can browse to your extracted folder of the SchemeWay update pack.

7. After couple of Ok presses Eclipse will show that it found the SchemeWay plugin. Then go ahead and install it.

8. Once everything is done, you can switch to the Scheme perspective from Window --> Open Perspective --> Other --> Scheme

9. Next task is to set the Scheme interpreter. I use the free version of Chez Scheme (i.e. Petite). So I have to set my interpreter as an external interpreter. To do this click Scheme --> Select Interpreter --> External Interpreter.

10. Now you have to give the necessary parameters to the plug-in to start your interpreter. To do this click Window --> Preferences. It will show you the preference window. On the left hand side of it you can expand the Scheme configurations. Select the External Interpreter configurations from there and set the necessary parameters.

Great! now you are good to go. Just create a new project and add a new Scheme source file. Then once you are done with typing your code, you can load it to the interpreter using CTRL+SHIFT+L.

You can play around a bit and get use to many other key short cuts.

One thing to note: you will have to set the indentation for some definitions to suit your style. You can do this by going to the same scheme configuration from Window --> Preferences.

Scheme: Trace Functions

I found this really useful command in Scheme which helps to trace the function calls, while playing around it.

Say you have define a function named func. Now if you want to trace how it works when you invoke it, just type this.

> (trace func)

The next time you invoke func you will see the trace of function calls.

Running Scheme on Ubuntu 8.04

Just hitting "scheme" in the console does no good if you are in Ubuntu 8.04. A workaround is explained here (http://ubuntuforums.org/showthread.php?p=4868292)

Here's the solution in brief:

sudo sysctl -w vm.mmap_min_addr=0

Now run scheme