| stack-specification - Et eksempel på en algebraisk specifikation af en stak. | Lecture 9 - slide 4 : 31 Program 1 |
Type stack [int]
declare
constructors
new () -> stack;
push (int, stack) -> stack;
destructors
pop (stack) -> stack;
selectors
top (stack) -> int;
empty (stack) -> bool;
for all
i in int;
s in stack;
let
pop (new()) = error;
pop (push (i,s)) = s;
top (new()) = error;
top (push (i,s)) = i;
empty (new()) = true;
empty (push(i,s)) = false;
end
end stack.
|