summaryrefslogtreecommitdiff
path: root/stdlib/stack.ml
diff options
context:
space:
mode:
authorNo author <no_author@ocaml.org>2002-01-04 03:39:47 +0000
committerNo author <no_author@ocaml.org>2002-01-04 03:39:47 +0000
commita8bf6e66adbcd28cedb7e1abc5ca6152adac0fda (patch)
treedba446d3ae9523002b7920ac5f63f0d86a33a8d3 /stdlib/stack.ml
parent953a344a65e14b9857ab2c9bfc16ffd90815eb17 (diff)
downloadocaml-a8bf6e66adbcd28cedb7e1abc5ca6152adac0fda.tar.gz
This commit was manufactured by cvs2svn to create branch 'poly_meth2'.
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/poly_meth2@4215 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'stdlib/stack.ml')
-rw-r--r--stdlib/stack.ml40
1 files changed, 40 insertions, 0 deletions
diff --git a/stdlib/stack.ml b/stdlib/stack.ml
new file mode 100644
index 0000000000..f49ed547fa
--- /dev/null
+++ b/stdlib/stack.ml
@@ -0,0 +1,40 @@
+(***********************************************************************)
+(* *)
+(* Objective Caml *)
+(* *)
+(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
+(* *)
+(* Copyright 1996 Institut National de Recherche en Informatique et *)
+(* en Automatique. All rights reserved. This file is distributed *)
+(* under the terms of the GNU Library General Public License, with *)
+(* the special exception on linking described in file ../LICENSE. *)
+(* *)
+(***********************************************************************)
+
+(* $Id$ *)
+
+type 'a t = { mutable c : 'a list }
+
+exception Empty
+
+let create () = { c = [] }
+
+let clear s = s.c <- []
+
+let copy s = { c = s.c }
+
+let push x s = s.c <- x :: s.c
+
+let pop s =
+ match s.c with
+ 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