Ajout Stack.top
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@3072 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02master
parent
a5eafc35c6
commit
e27406829f
|
@ -27,6 +27,11 @@ let pop s =
|
|||
hd::tl -> s.c <- tl; hd
|
||||
| [] -> raise Empty
|
||||
|
||||
let top s =
|
||||
match s.c with
|
||||
hd::_ -> hd
|
||||
| [] -> raise Empty
|
||||
|
||||
let length s = List.length s.c
|
||||
|
||||
let iter f s = List.iter f s.c
|
||||
|
|
|
@ -29,6 +29,9 @@ val push: 'a -> 'a t -> unit
|
|||
val pop: 'a t -> 'a
|
||||
(* [pop s] removes and returns the topmost element in stack [s],
|
||||
or raises [Empty] if the stack is empty. *)
|
||||
val top: 'a t -> 'a
|
||||
(* [top s] returns the topmost element in stack [s],
|
||||
or raises [Empty] if the stack is empty. *)
|
||||
val clear : 'a t -> unit
|
||||
(* Discard all elements from a stack. *)
|
||||
val length: 'a t -> int
|
||||
|
|
Loading…
Reference in New Issue