* [Caml-list] Format
@ 2001-05-06 17:42 Vasilij Karpow
0 siblings, 0 replies; only message in thread
From: Vasilij Karpow @ 2001-05-06 17:42 UTC (permalink / raw)
To: caml-list
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2001-05-06 17:42 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-05-06 17:42 [Caml-list] Format Vasilij Karpow
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox