Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
25
Task/Stack/Elisa/stack-2.elisa
Normal file
25
Task/Stack/Elisa/stack-2.elisa
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
component GenericStack ( Stack, ElementType );
|
||||
type Stack;
|
||||
Stack(MaxSize = integer) -> Stack;
|
||||
Empty( Stack ) -> boolean;
|
||||
Full ( Stack ) -> boolean;
|
||||
Push ( Stack, ElementType)-> nothing;
|
||||
Pull ( Stack ) -> ElementType;
|
||||
begin
|
||||
type sequence = term;
|
||||
ElementType & sequence => sequence;
|
||||
nil = null (sequence);
|
||||
|
||||
head (sequence) -> ElementType;
|
||||
head (X & Y) = ElementType:X;
|
||||
|
||||
tail (sequence) -> sequence;
|
||||
tail (X & Y) = Y;
|
||||
|
||||
Stack (Size) = Stack:[ list = nil ];
|
||||
Empty ( stack ) = (stack.list == nil);
|
||||
Full ( stack ) = false;
|
||||
Push ( stack, ElementType ) = [ stack.list:= ElementType & stack.list ];
|
||||
Pull ( stack ) = [ exception (Empty (stack), "Stack Underflow");
|
||||
Head = head(stack.list); stack.list:=tail(stack.list); Head];
|
||||
end component GenericStack;
|
||||
Loading…
Add table
Add a link
Reference in a new issue