1 (***********************************************************************)
5 (* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
7 (* Copyright 1996 Institut National de Recherche en Informatique et *)
8 (* en Automatique. All rights reserved. This file is distributed *)
9 (* under the terms of the GNU Library General Public License, with *)
10 (* the special exception on linking described in file ../LICENSE. *)
12 (***********************************************************************)
14 (* $Id: stack.ml 4956 2002-06-27 08:48:26Z xleroy $ *)
16 type 'a t = { mutable c : 'a list }
20 let create () = { c = [] }
22 let clear s = s.c <- []
24 let copy s = { c = s.c }
26 let push x s = s.c <- x :: s.c
30 hd::tl -> s.c <- tl; hd
38 let is_empty s = (s.c = [])
40 let length s = List.length s.c
42 let iter f s = List.iter f s.c