.TH "Stack" 3o source: 2016-12-21 OCamldoc "OCaml library" .SH NAME Stack \- Last-in first-out stacks. .SH Module Module Stack .SH Documentation .sp Module .BI "Stack" : .B sig end .sp Last\-in first\-out stacks\&. .sp This module implements stacks (LIFOs), with in\-place modification\&. .sp .sp .sp .I type .B 'a .I t .sp The type of stacks containing elements of type .B \&'a \&. .sp .I exception Empty .sp Raised when .B Stack\&.pop or .B Stack\&.top is applied to an empty stack\&. .sp .I val create : .B unit -> 'a t .sp Return a new stack, initially empty\&. .sp .I val push : .B 'a -> 'a t -> unit .sp .B push x s adds the element .B x at the top of stack .B s \&. .sp .I val pop : .B 'a t -> 'a .sp .B pop s removes and returns the topmost element in stack .B s , or raises .B Empty if the stack is empty\&. .sp .I val top : .B 'a t -> 'a .sp .B top s returns the topmost element in stack .B s , or raises .B Empty if the stack is empty\&. .sp .I val clear : .B 'a t -> unit .sp Discard all elements from a stack\&. .sp .I val copy : .B 'a t -> 'a t .sp Return a copy of the given stack\&. .sp .I val is_empty : .B 'a t -> bool .sp Return .B true if the given stack is empty, .B false otherwise\&. .sp .I val length : .B 'a t -> int .sp Return the number of elements in a stack\&. .sp .I val iter : .B ('a -> unit) -> 'a t -> unit .sp .B iter f s applies .B f in turn to all elements of .B s , from the element at the top of the stack to the element at the bottom of the stack\&. The stack itself is unchanged\&. .sp