IM269: Declarative Programming

Lecturer: Sebastian Danicic


This module investigates declarative programming using the functional programming language Hope.


Coursework 1: Conway's Game of Life

There is a square grid. Each cell in the grid can contain a bacterium or be empty. Each cell has 8 neighbours except that cells on the boundary have less than 8 neighbors. The population increases and decreases according to fixed rules which affect the birth and death of each individual bacterium. The existence of cells from one generation to the next is determined by the following rules:

1. A bacterium with 2 or 3 neighbours survives from one generation to the next. A bacterium with fewer neighbours dies of isolation. One with more neighbours dies of overcrowding.

2. An empty cell spawns a bacteria if it has exactly three neighboring cells which contain bacteria.

Using a representation of the board as a list of lists, write a hope function: generate, which given any starting position, produces the next generation. (10%)

Bonus marks of up to 10% (of the total unit mark) will be given for the generality of your solution.

Submitted Work


Coursework 2: Noughts and Crosses

Think of a way of representing a Noughts and Crosses (Tic Tac Toe) board in Hope.

Write a function which takes a board and produces all possible positions that can be produced in the next move.(15%)

Bonus marks up to 15% will be given for the generality of your solution and for making up some of your own relevant and interesting functions.

Submitted Work


Coursework 3: A Journey Planner

Give a Hope representation for the London Tube Map.

Write a hope function which takes three parameters: a representation of the map, the first station and the last station and outputs all cycle free routes (a route is a list of stations) between the first and the last station. (20%)

Bonus marks up to 20% will be given for making up some of your own useful functions.

Submitted Work


Go To: Eamonn's Place : Education