Computer Science Department
Programming Methods Laboratory

Foundations of Programming
Ecole Polytechnique Federale de Lausanne
Exercises 5
03/05/2001

The task of this exercise is to implement Queues in Funnel using join synchronization. In a queue, data is stored and retrieved according to the FIFO (first in first out) principle. The following Funnel type describes the operations a queue supports:
newtype Queue[a] = {
    def get: a
    def put(x: a): ()
}
With put, a new element x is appended to the end of a queue. get returns the first available element. Implement a constructor newQueue[a] that returns an empty queue of the given type Queue[a]:
def newQueue[a]: Queue[a] = {
    ...
}
Your implementation should be synchronized, so that it can be used in concurrent programs.