Due: Thursday, February 26th at the start of class
Reading: Chapter 4, 5, and 6 of Programming Erlang
You are again welcome to work with others for this assignment, but each
person must turn in their own code.
Overview
The goal of this assignment is to finish up some of the details with
sequential programming in Erlang. We will now assume you know all of
the material in Chapters 4, 5 and 6. This assignment just exercises
your ability to throw and catch exceptions, print
messages to the terminal, and run your code as an escript.
We'll again be extending our program from Assignments 1 and 2; you are
free to use your previous solution or one of the others given in class.
Experimental Platform
This time, all of your code should be placed in an escript. You can
run your program this way by putting the following line at the top of
your file:
#!/usr/bin/env /s/erlang/bin/escript
Two Very, Very Simple Steps
The first change is make your function count throw two
different exceptions. The first exception should be used to designate
that the argument passed to count is not a list of course
records. The second exception can be any problem of your own devising
(e.g., a year is not in realistic range or a course is not a known CS
course).
The second change is to write a function main that calls
make_list (or some variants) and count, catching the
exceptions as desired. Have main call count with
different arguments to stress the two exceptions as well as the normal
case. You should use io functions within main to print
out the list returned by count or to print out sensible error
messages.
Again, comment your code enough that someone can follow what you did.
Turning in your assignment
Please bring to class a print out of your commented Erlang escript
file. Also, bring a print out showing the output of your script.
Please also copy your code to the directory
~cs739-1/Spring09/handin/[login]/P3 where [login] is your CS
login name.
We won't grade you on elegance, or simplicity, or creativity, or
anything other than functionality and comments. If different students
come up with wildly different solutions, we'll try to share some of the
different approaches.
Happily, our next assignment will be using the concurrent features of
Erlang. Finally!