(* obligation : Le nom d'un module commence par une majuscule *) module Pile_liste = struct type 'a t = { mutable c : 'a list } exception Empty let create () = { c = [] } let clear p = p.c <- [] let push x p = p.c <- x::p.c let pop p = match p.c with [] -> raise Empty |x::reste -> p.c <- reste; x let top p = match p.c with [] -> raise Empty |x::_ -> x let length p = List.length p.c let iter f p = List.iter f p.c let inutile () = true end;; module Pile_liste = (Pile_liste : PILE);; (* # let p = Pile_liste.create();; val p : '_a Pile_liste.t = # Pile_liste.push 2 p;; - : unit = () # Pile_liste.push 3 p;; - : unit = () # Pile_liste.push 4 p;; - : unit = () # Pile_liste.length p;; - : int = 3 # Pile_liste.iter (fun x -> Printf.printf "%d " x) p;; 4 3 2 - : unit = () *)