Lecture 11 and 12

Lectures this week covered up to slide 39 of the lecture slides.

The current topic is abstract types. These lectures covered various implementations of sets in Haskell to motivate the use of data abstraction which will be covered next week.

For now, a teaser: the secret to data abstraction is being selfish and possessive, like a 5-year-old child with a favourite toy.  All will be explained next week!

The reading assignment this week is chapters 15 ad 16 from the textbook. Keep reading!

— Chris.

 

Posted in Uncategorized | Leave a comment

Lectures 9 and 10

This week, lecture 9 covered slides 1 to 23 and lecture 10 covered slides 24 to 39 of the lecture slides.

You should have learnt about defining and working with  algebraic data types.

The reading for this week is chapters 13 to 14 of the textbook, pages 287 to 356.

Remember to keep up with the reading! The textbook covers things in more detail than the lectures and has exercises to help you learn. Try doing the easy exercises in the textbook before you attempt the tutorial exercises.

— Chris.

Posted in Uncategorized | Leave a comment

Lecture 8

Today’s lecture covered slides 38 to the end of these lecture slides and slides 1 to 9 and 20 to 41 of these lecture slides.

You should have learnt about:

  • currying,
  • lambda expressions,
  • binding of variables and functions,
  • local binding with where clauses.

— Chris

Posted in Uncategorized | Leave a comment

Lecture 7

Today’s lecture covered slides 51 to 61 of these lecture slides and slides 1 to 37  of these lecture slides.

You should have learnt about the higher order functions:

  • Map
  • Filter
  • Fold

The reading assignment this week was to finish chapters 8 to 9 of the text book. Next week (from 15th Oct.) there are no lectures, but the reading will be chapters 10 to 12 of the textbook.

— Chris

Posted in Uncategorized | Leave a comment

Lecture 6

Today’s lecture covered slides 29 to 50 of the lecture slides.

The reading assignment is to continue with chapters 8 to 9 of the textbook.

You will have learnt about:

  • counting (or enumeration) functions;
  • more functions on lists: zip, search, select, take, and drop.

Note:

The take and drop functions (introduced in the last slides) are useful for this week’s tutorial exercise!

IMPORTANT NOTE:

There will be an extra tutorial on Wednesday afternoon of week 5 for those who require extra preparation for the class test. Please:

  • indicate your time constraints here;
  • attempt the 2011 class test before the tutorial;
  • print out and bring your solutions!
Posted in Uncategorized | 2 Comments

Lecture 5

This lecture covered up to slide 28 in the lecture slides.

The reading assignment for this week is chapters 8 to 9 from the textbook (pp. 177-212).

You should have learnt about:

  • conditionals — both conditional equations (using guards) and conditional expressions (if..then..else).
  • associativity and infix notation
  • the append (++) list function

Note:

Exceptionally, there will be FP lectures this week on Monday, Tuesday, and Friday.  There is a talk from the careers service on Thursday.

There will be no Inf1-CL lectures this week. Next week, there are no FP lectures, just CL lectures.

Inf1-FP tutorials run as usual in both weeks.

–Chris

Posted in Uncategorized | Leave a comment

Lecture 4

The fourth lecture covered slides 10-60 in the lecture slides.

You should have learnt about recursion, the definition of recursive functions, and recursive data structures (now you know that a list is a recursive data structure).

Remember to carry on reading chapters 4 to 7 in the textbook (pp. 67-176).

Extra note:

In the last two lectures you’ve been introduced to QuickCheck. QuickCheck does random testing on functions. This is a very useful tool for testing functions, but it relies on the fact that give some input a function always has the same output. This is of course true in Haskell. If f(x)=y then f(x) always equals y.

You give QuickCheck your function and a property that is true of all results of the function. QuickCheck generates a set of random inputs to your function and then checks that for every input the property is true. Of course, you have to be careful about the property you choose!

In other languages random testing is not quite as useful. A Java method, for example, does not always return the same result for some input. In Java f(x) does not always equal y. For example, f might depend on something in memory or some user input. In Haskell this is not the case.

One of the most powerful aspects of functional programming is this absence of state, that is the state of the world (memory, hard disk, user, network, etc.) does not affect the outcome of the function. Later on in the course you will learn how to deal with these necessary interactions with the world.

Chris

Posted in Uncategorized | 1 Comment

Lecture 3

The third lecture covered up to slide 9 in the lecture slides.

You should have learnt about lists, list comprehensions, and QuickCheck and you should now be able to attempt the list comprehension parts of the tutorial exercise.

The required reading is chapters 4 to 7 in the textbook (pp. 67-176).

Today’s material was particularly important because lists are a fundamental data structure in Haskell. Understanding how lists, comprehensions, and recursion (to come in the next lecture) work are key to understanding the rest of the course. Much of the material to come will be built upon these concepts. So:

  • Keep on top of the reading! There is a lot of material in the textbook so reading small sections frequently will allow you to get through it all in time for the next class. Try the exercises!
  • Get started on the tutorial exercises! You must have these done ready for your tutorial class. The sooner  you start, the more time you’ll have to ask for help if you get stuck. And do ask for help.
  • There are no silly questions, only silly people who don’t ask questions!
  • Don’t forget that you can ask questions by posting comments on this blog. This is useful for your classmates as everyone will see the answers.

Extra notes:

Also in today’s lecture pairs were introduced. A pair (a,b) and in general an n-tuple (a,b,c,…) differs from a list in the following ways:

  1. Lists can hold an arbitrary number of items, but tuples contain a fixed number (e.g. a pair contains two items, a triple or 3-tuple contains three items, an n-tuple contains n items).
  2. The items in a list must all be of the same type, but in a tuple each item may have a different type.
Posted in Uncategorized | 8 Comments

Lecture 2

The second lecture covered up to page 27 of the first set of lecture slides.

You should have learned how to apply functions to data, combine or compose functions, and define new functions.

The reading assignment is to continue with chapters 1 to 3 of the textbook (see the previous post).

Remember: functional programming is is like poetry — whilst sometimes it may look obscure, it is concise, precise, and beautiful.

Links from today’s lecture:

— Chris

Posted in Uncategorized | Leave a comment

Lecture 1

The first lecture covered up to page 15 of the first set of lecture slides.

The required reading for this week, from the course textbook:

Haskell: The Craft of Functional Programming (Third Edition)
Simon Thompson, Addison-Wesley, 2011.

will be Chapters 1, 2, and 3 (pp. 1-66). Three whole chapters might seem a bit daunting at first, but it is mostly introductory material and quite easy to read. Some of this material is directly relevant to this week’s lab exercise.

Printed copies of the lab exercise will be available from the ITO. In subsequent weeks, the tutorial exercises will be handed out in hard copy in Monday’s lecture; they will, of course, also be available from the course website.

Also: check out the Land of Lisp music video. The language Lisp was the first functional programming language. Amongst many other things, Lisp is famous for requiring a lot of parentheses!

— Chris.

Posted in Uncategorized | Leave a comment