From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id TAA09758; Sun, 6 May 2001 19:42:26 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id TAA09497 for ; Sun, 6 May 2001 19:42:25 +0200 (MET DST) Received: from yr ([195.159.42.21]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f46HgOf11433 for ; Sun, 6 May 2001 19:42:24 +0200 (MET DST) Received: from malc by yr with local (Exim 3.22 #1 (Debian)) id 14wSYB-0001gR-00 for ; Sun, 06 May 2001 19:42:31 +0200 Date: Sun, 6 May 2001 19:42:31 +0200 To: caml-list@inria.fr Subject: [Caml-list] Format Message-ID: <20010506194231.A6460@yr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.17i From: Vasilij Karpow Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk I wonder if anyone can teach me properly outputing values of following type: type sexp = | Slist of (string * lsexp) | Satts of lsexp | Sbody of lsexp | Sattr of (string * string) | Sdata of string and lsexp = sexp list. Even default(and hence dumb) interactive ocaml toplevel printer does it better than my own attempts of abusing Format. let rec print_sexp pff = function | Slist (n, l) -> fprintf pff "@ @,@[<1>(%s %a)@]" n print_lsexp l | Sbody b -> print_lsexp pff b | Satts a -> fprintf pff "@[(%a)@]" print_lsexp a | Sattr (n, a) -> fprintf pff "@[%s: \"%s\"@ @]" n (attr_value a) | Sdata s -> fprintf pff "@ \"%s\"" (String.escaped s) and print_lsexp pff l = List.iter (print_sexp pff) l I must confess though, i do not fully understand what im doing here. So please anyone. P.S. Oh btw. this is NOT an assignment ;) -- mailto:malc@boblycat.com ------------------- To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr