Pragmattica

November 23, 2007

Getting Started with Scheme on Ubuntu — Part 1

Filed under: Linux,Scheme — bnsmith @ 3:44 am

Installing Gambit Scheme

As I described in my previous post, I am a fan of the Gambit implementation of Scheme. While following these instructions, try to keep in mind that the Scheme community is smaller than the communities of the more major languages like Python or Ruby, so there are still rough edges that get in the way. I hope that my experiences can speed things up for other fledgling Schemers.

It is possible to install Gambit Scheme from the Ubuntu repositories. However, the repositories contain an older version, so I recommend building Gambit Scheme from source instead. First, go to the Gambit Scheme website.

pic11.png

Click on the “Sources” link and save the gambc-v4_1_0.tgz file to your home directory. Next, open up a terminal (Applications -> Accessories -> Terminal), and enter these commands:

tar -xzvf gambc-v4_1_0.tgz
cd gambc-v4_1_0
./configure && make
make check
sudo make install
sudo make bootstrap
cd /usr/bin
sudo ln -s /usr/local/Gambit-C/current/bin/gsi gsi
cd ~

Once the installation is complete, conduct a few tests. From your terminal, enter the command:

gsi

You should then see Gambit’s interactive interpreter prompt. Enter the following code:

(define numlist '(2 10 6))
(map (lambda (x) (* x x)) numlist)

You should receive these results:

pic21.png

Exit the interpreter, by pressing CTRL-D twice. You can also use the Gambit Scheme interpreter to run Scheme programs stored in files. As an example, put the following text into a file named hello.scm:

(display "Hello World!\n")

Run the file with the command:

gsi hello.scm

That should be enough to start experimenting with Scheme. Part 2 will describe the installation and use of the SLIB libraries.

Advertisements

4 Comments

  1. the command should be:

    “(include \”/usr/local/lib/slib/gambit.init\”)” > ~/.gambcini
    ^ was missing

    Also, on my Firefox browser, the commands were just one long line all run together. If you make them look like this, they can be read and used:

    tar -xzvf gambc-v4_1_0.tgz
    cd gambc-v4_1_0
    ./configure && make
    make check
    sudo make install
    sudo make bootstrap
    cd /usr/bin
    sudo ln -s /usr/local/Gambit-C/current/bin/gsi gsi
    cd ~

    Jim

    Comment by Jim Entwisle — February 12, 2008 @ 3:51 am

  2. the damn thing re-formatted what I wrote. I was trying to say that the fullstop(period) was missing before the word `gambcini’ in the original command.

    Jim

    Comment by Jim Entwisle — February 12, 2008 @ 3:55 am

  3. Thanks for the info, Jim. It seems that some formatting was lost in my recent move from Blogger. Come to think of it, it seems there may be some missing images, too. I’ll have to go over all my posts carefully.

    Comment by bnsmith — February 12, 2008 @ 1:47 pm

  4. sudo apt-get install gambc

    Comment by alvin — May 8, 2011 @ 6:52 pm


RSS feed for comments on this post.

Blog at WordPress.com.

%d bloggers like this: