Distance Course (2AD200)
in the Maths & Natural Sciences programme (MN)
at Uppsala University, Sweden
Tasks of Lab 0
Nothing has to be handed in about your activities in this lab.
- Start SML/NJ in interactive mode: enter sml to the Unix
prompt and see what happens.
- Try and evaluate several SML expressions (one- and multi-line).
Program and test a couple of functions, like factorial or the
Fibonacci series. Analyse SML/NJ responses. Try and give
erroneous inputs, and analyse the results.
- Become comfortable with the interactive mode.
- Learn what use "foo.sml" ; serves for.
- Now you are ready to edit and save SML programs in your favourite
editor: run and debug them in SML.
- A much better way to proceed is as follows:
- Type xemacs myprog.sml & and see what happens. Try also
emacs myprog.sml &. You might need to update your
~/.emacs or ~/.xemacs/init.el file by adding lines
from our sample init.el file.
- Analyse the [x]emacs toolbar: do you notice anything SML-related?
- Investigate the SML menu and learn how to start SML/NJ.
- It should split your [x]emacs windows in two: in one you edit your
program and send it to the other, in which you run SML/NJ
interactively. This allows convenient and efficient SML
- Learn and use as much as you can about the options provided in the
- For example, type fun factorial 0 = 1 in myprog.sml and
then try electric pipe. You will enjoy how comfortable
- Try and insert forms, etc. Become friendly with this environment.
- If you do not come here every day, install SML/NJ and [x]emacs on
your home computer: the instructions and references are provided
on the course homepage.
- Spend as much time as you can trying to understand and practice
functional programming. First it may seem difficult, but your
efforts will be quickly and generously rewarded. Functional
programming is fun and easy: you will like it.
- Proceed to Assignment 1. Do not
despair if you cannot yet do everything. Do as much as you can.
We understand you may have different backgrounds and preliminary
knowledge. Sometimes you have difficulties to start. We have
seen many students who made a tremendous breakthrough from zero
knowledge to mastering and loving FP in a short period of time.
- If, on the other hand, you do not feel the assignments are
difficult enough for you, try and solve your own problem/puzzle
using SML, or ask us to give you a problem to try. Usually,
well-known simple problems, like 8 queens, knight's tour, or
sorting give you good opportunities to compare FP with imperative
programming, and get a real impression of the advantages of FP,
both in simplicity and efficiency.
- Have fun!
Last modified: Thu Sep 25 15:00:42 MEST 2003