| << Prev | - Up - | Next >> |
For are going to implement the agenda by a stack. These are provided as abstract data structure (ADS) as already discussed in Section on Modules in the Chapter on functional programming:
%% maybe you want to change this URL to
%% the appropriate local filename
declare URL ='http://www.ps.uni-sb.de/~niehren/Web/Vorlesungen/Oz-NL-SS01'
declare ADS_URL = URL#'/vorlesung/Functors/Version.3.2/Abstract.ozf'
%% load the module with the abstract data structures
declare [ADS_Module] = {Module.link [ADS_URL]}
%% select the abstract data structure for the stack
declare NewStack = ADS_Module.newStack
%% implement agendas through stacks
declare NewAgenda = NewStackAgendas are thus stacks. These are records whose programming interface is described by the following type:
unit(
push : Value ->
pop : -> Value
isEmpty: -> Bool
...
) If A is an agenda, then {A.push X} adds item X to the agenda, {A.pop} removes and returns an item from the agenda, and {A.isEmpty} returns true iff there are no items in the agenda.
Here, we used a stack, but we could just as easily have used a queue. In fact, as long as we provide the same programming interface, we can use any implementation we please.
| << Prev | - Up - | Next >> |