UW-Madison
Computer Sciences Dept.

CS739 Spring 2009: Programming Assignment 1 -- Erlang Warm-Up

Due: Thursday, January 29th at the start of class
Reading: Chapter 2 of Programming Erlang

You are 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 get you started using Erlang. This short assignment will verify that you understand basic pattern matching with variables, atoms, tuples, and lists. It should be a very, very simple assignment to complete and requires no reading beyond Chapter 2.

Experimental Platform

Erlang has been installed on the instructional and research Linux machines in the CS department.

You can use just the Erlang shell (available from /s/erlang/bin/erl) for this assignment.

Two Simple Steps

  1. Create an Erlang list of your three favorite courses that you've taken since you've been a graduate student at Wisconsin. (Make sure the list contains at least three courses; you can make them up if need be.)

    Each course is a nested set of tuples, with a tuple for the name of the course (e.g., Distributed Systems), its number (e.g., 739), its instructor (e.g., Arpaci-Dusseau), and the year you took the course (e.g, 2009). The first element of every tuple (including the top-level tuple) is an atom properly describing the tuple (e.g, instructor).

  2. After you've constructed the list of three tuples, write a pattern to extract the instructor for the first course in any list constructed like this. Do as much error checking within your pattern as possible (i.e., check that all of the atoms are as expected). Assign a variable for the instructor of the first course and display its value.

Turning in your assignment

For this assignment, you just need to turn in your shell session. You don't need to write up any kind of report or include any comments. Just bring to class a printout with the shell code and how it was evaluated.

Make sure that your shell session shows 1) how you set up the list, 2) your pattern for extracting the first instructor, and 3) the value for the first instructor.