Functional programming -- 2009-2010 -- info.uvt.ro/Laboratory/Tools
Overview
edit- Scheme implementation;
- PLT Scheme -- official site;
- PLT Scheme Win32 package;
- Common Lisp implementation;
- GNU CLISP -- official site;
- GNU CLISP Win32 package;
- SSH client for remote access to the university's server
r2d2.info.uvt.ro
; - PuTTY -- official site;
- PuTTY Win32 package;
- Lisp aware text editor for Windows and Linux;
- SciTE -- official site;
- NotePad++
- Lisp aware text editor for Windows;
- NotePad++ -- official site;
- NotePad++ Win32 package;
How to work with PLT Scheme
edit- Using DrScheme (recommended)
DrScheme is a nice graphical shell that allows us to interact with PLT Scheme.
First we must start it:
- we can start it either by searching its icon on the desktop or through the Start Menu -> Applications for Windows or by searching it inside the Applications -> Programming in (Ubuntu) Linux (the logo is );
- we have to check if the version is at least 4.x.x (in previous versions it was numbered like 372, and there were radical changes between 3xx and 4.x.x); to check this we can look inside the Help -> About DrScheme;
- another way to check the version is to enter the
(version)
statement inside the textbox in the lower-half of the window;
- another way to check the version is to enter the
- please note that in our laboratories the 4.x.x version of PLT Scheme in available only from the NetBoot Linux, and must be started by typing
/opt/plt/drscheme &
in a terminal, then closing the terminal;
Analyzing the DrScheme user interface we can see:
- the menu with the options File, Edit, ...;
- the toolbar with some buttons Save, ..., Check Syntax, Run, Stop;
- a textbox, in the upper half of the window, with the
#lang scheme
text in there -- this is the source code editor; - another textbox, in the lower half of the window, with a Welcome ... message -- this is the shell;
Usually we use DrScheme as follows:
- for simple expressions and experiments we use the shell window where we just write the code, press enter and we see the result;
- for more complex exercises we use the text editor to write the source code (do not remove the
#lang scheme
text from the beginning of the file):- we first define any functions or constants we need (like
(define (sum a b) (+ a b))
); - then we make sure that we call the functions and we also printout their result (like
(print (sum 1 2))
); - and finally we just press the Run button from the toolbar;
- (in case our application refuses to finish (because we made an infinite loop) we can just press the Stop button);
- after we made sure everything works right we can just save our work by pressing the Save button; the usual extensions for Scheme files are ss or scm (please note that in our laboratories, and in general on any Linux, you are allowed to save files only inside your home-folder (the default location proposed to you by the save dialog));
- we first define any functions or constants we need (like
- Using MzScheme
MzScheme is another shell that allows us to interact with the PLT Scheme, but aside from DrScheme this is a console shell. (It is also used to allow us to run unattended Scheme scripts.)
To start it we need:
- to open a terminal, in Windows we start the cmd.exe from the Run... menu, and under Linux we can choose the Terminal option from the Applications -> System Tools menu;
- we have to check if the version is at least 4.x.x (in previous versions it was numbered like 372, and there were radical changes between 3xx and 4.x.x); to check this we run the command
mzscheme --version
inside the terminal;- another way to check the version is to enter the
(version)
statement inside the shell if we have started it by just typingmzscheme
- another way to check the version is to enter the
- please note that in our laboratories the 4.x.x version of PLT Scheme in available only from the NetBoot Linux, and must be started by typing
/opt/plt/mzscheme
in a terminal;
Using MsScheme shell is quite similar with using DrScheme:
- for simple expressions we just write the code in the shell and see their outputs;
- for more complex exercises we usually do the following:
- we edit the source code (in another terminal on Linux this can be done with
nano
,mcedit
,emacs
or whatever editor feels right for you) (also in Linux we can use a graphical editor like Gedit available from Applications -> Accessories -> Text Editor, and on Windows we could use Scite or NotePad++ presented above):- we first define any functions or constants we need (like
(define (sum a b) (+ a b))
); - then we make sure that we call the functions and we also printout their result (like
(print (sum 1 2))
); - we save the file, the usual extensions for Scheme files are ss or scm;
- we first define any functions or constants we need (like
- (if we entered
mzscheme
as presented in the previous steps we need to exit from there by typing(exit)
); - we just type
mzscheme my-program.ss
; (or if in our laboratories/opt/plt/bin/mzscheme my-program.ss
);
- we edit the source code (in another terminal on Linux this can be done with
How to work with GNU CLisp
editTo start it we need to open a terminal, in Windows we start the cmd.exe from the Run... menu, and under Linux we can choose the Terminal option from the Applications -> System Tools menu (just like for MzScheme).
Using GNU CLisp shell (just like for MzScheme):
- for simple expressions we just write the code in the shell and see their outputs;
- for more complex exercises we usually do the following:
- we edit the source code (in another terminal on Linux this can be done with
nano
,mcedit
,emacs
or whatever editor feels right for you) (also in Linux we can use a graphical editor like Gedit available from Applications -> Accessories -> Text Editor, and on Windows we could use Scite or NotePad++ presented above):- we first define any functions or constants we need (like
(defun sum (a b) (+ a b))
); - then we make sure that we call the functions and we also printout their result (like
(print (sum 1 2))
); - we save the file, the usual extension for Common Lisp files is cl;
- we first define any functions or constants we need (like
- (if we entered
clisp
as presented in the previous steps we need to exit from there by typing(exit)
); - we just type
clisp my-program.cl
;
- we edit the source code (in another terminal on Linux this can be done with