DM22, Spring 2007 - Weekly Note 1


Lecture February 5 (Expected contents)

Introduction to course. Major programming language categories.

Introduction to Haskell: Functions, the Hugs interpreter, basic types, operators, polymorphism, functions as parameters and results, pattern matching.

Reading

Chapter 1 in Bird. Slides (Intro to Course, Haskel Intro I). You may also browse the following code examples.

Remarks

The textbook is a solid introduction to functional programming as a science. However, as an introduction to the langauage Haskell it is a bit sketchy. More precisely, a large number of parts of Haskell are touched upon in Chapter 1, but only with a passing mentioning. The book is not meant as a documentation of the language Haskell (and will not serve well as such), but as an introduction to functional programming. A more thorough coverage of Haskell elements are found in the slides from the lectures, and in the additional material on the main course page. In particular, it is necessary to read the lecture slides along with Chapter 1 (and to some extent with Chapters 2 and 3).

A main aim of Birds book is to teach functional programming as a mathematical activity. In this course, we initially will concentrate on learning Haskell the language, and getting some code running. Although it is one of the key virtues of functional programming that it is much easier to reason about than imperative programming, we will postpone this subject until a bit later in the course. Hence, for the moment you can (and probably should) skip all parts of the sections read which deal with proofs of identities, as well as those dealing with the undefined value ("bottom") and strict and non-strict functions. We will return to these later. Instead, put some time into reading the slides, and browse some of the material under point "Additional Material" at the main course page.


Exercises February 8

Exercises 1.1.1, 1.1.2, 1.1.3, 1.5.1, 2.4.3, 4.2.8 and 4.3.1 in Bird.

Define a function

elemNum :: [Int] -> Int -> Int
such that elemNum xs x counts the number of times that x appears in the list xs.

Define a function

remove :: Int - [Int] -> [Int]
such that remove x xs returns the list xs with all occurences (if any) of x removed.

Define a function

uniques :: [Int] -> [Int]
such that uniques xs returns the list of elements which appear exactly once in the list xs.

Define a function

mkSet :: [Int] -> [Int]
such that mkSet xs returns the list of elements of xs, but now with any repeated elements removed (that is, each element should appear only once).

Exercises 1.4.1, 1.4.6, and 1.4.7 in Bird.


Maintained by Rolf Fagerberg (rolf@imada.sdu.dk)