codeworld-base-0.2.0.0: Replacement base module for CodeWorld

Safe HaskellNone
LanguageHaskell98

Extras.Queue

Description

A Queue is a structure similar to a List, but elements are added to one end (the back) and retrieved from the other end (the front). Thus, a Queue is a FIFO (first-in first-out) structure, just like waiting lists that are served in the order of arrival.

Synopsis

Documentation

A Queue

To use the extra features in this module, you must begin your code with this line:

import Extras.Queue

data Queue a #

The internal structure of a Queue is not exposed. You need to use the functions in this module to manipulate it.

qNew :: Number -> Queue a #

A fresh new, empty Queue with the given Number as its identifier. Identifiers are arbitrary numbers that you can use to distinguish between several queues in your code.

qLength :: Queue a -> Number #

The number of elements currently waiting in the given Queue

qFront :: (Queue a, a) -> a #

qFront(queue,default) is either the front element at queue (when it is not empty) or default (when the queue is empty)

qRest :: Queue a -> Queue a #

A Queue like the given queue, but with the front element removed. If the given queue is empty, it remains unchanged.

qAppended :: (a, Queue a) -> Queue a #

A Queue like the given queue, but with the given element added to the back

qNumber :: Queue a -> Number #

The identifier associated to the given Queue