Get a Sparky account:
- Sparky is a big computer that many people can connect to
at once. Every Stony Brook student can have a Sparky account.
There are many things it can do for you, e.g., you can host your own
web pages there. In this class we use it as a place to run the SML
programming language.
- If you do not have a Sparky account, go to the SINC
site in the main library. Bring your ID. They can create the
account for you.
How to run SML:
- Connect to Sparky using SSH or telnet from any
computer at any SINC
site or from your own computer:
- At any SINC site, run SSH, connect to sparky.ic.sunysb.edu
and give it your user name
and password. You can install SSH on your own computer. Download
it free
from here.
- If you are working from your own PC and don't want to install
SSH, you can use telnet, which is already installed on Windows PCs.
(But telnet is not secure, so many people prefer SSH, which encrypts
your communication.) From
the Windows start menu, select Run..., and type "telnet", which
should cause telnet to run in a new window. In that window, type open
sparky.ic.sunysb.edu and you will then be prompted
for your user name and password.
- By either of the above methods, you will have a window open to
Sparky, which gives you various welcome messages and then a prompt "sparky%".
Sparky is a UNIX system, so upper case and lower case are distinct. At
the prompt, type sml (all lower case) to start the SML
program.
- SML will type "-" as its prompt. Type an expression, ending
it
with a semicolon and <enter>. SML will interpret it, name
the result "it", and print out its value and type as:
val it = <value> : <type>
- For example, type 2+2; and the output should be val
it = 4 : int
- Then, type 2*5; and the output should
be val
it = 10 : int
SML Details:
- If you need more than one line to type your input, you can hit
enter and continue on a second line. The prompt for a second line
is "=". If you see this because you forgot to type the semicolon,
just add it on the second line to finish the command.
- Ignore occasional output lines that begin with "GC ..." which is
just a report about the internal operation of "garbage collection".
- To exit SML, type <control>-d
- If you create an infinite recursion, stop it by typing
<control>-c
- To exit Sparky, type logout
- To edit typos, you
may want to write your function in a word processor window, edit there,
and copy to the SML window.
- When we study lists, you might need this command to change SML's
print settings:
Compiler.Control.Print.printLength := 1000;
Practice Problems:
- Try reproducing the output for all the SML examples demonstrated
in
class. For each example, also try a slight
variation of your own. Before hitting <enter> always think of
what you expect the output to be.
More:
- You may also want to read the
first few lessons
of this
online SML tutorial and do their self-tests as practice problems.
- You don't need this for CSE160, but someday you may want a Reference Manual.
- If you want to install sml on your
own computer, see the SML-NJ
web site. But there is no need to install SML on your computer if
you have an internet connection, as you can use SML on Sparky.