From: Vasilij Karpow <malc@boblycat.com>
To: caml-list@inria.fr
Subject: [Caml-list] Format
Date: Sun, 6 May 2001 19:42:31 +0200 [thread overview]
Message-ID: <20010506194231.A6460@yr> (raw)
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
reply other threads:[~2001-05-06 17:42 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20010506194231.A6460@yr \
--to=malc@boblycat.com \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox