caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Chris Hecker <checker@d6.com>
To: caml-list@inria.fr
Subject: [Caml-list] pretty printers and format and matrices
Date: Tue, 12 Jun 2001 11:18:13 -0700	[thread overview]
Message-ID: <4.3.2.7.2.20010612111351.029b8720@shell16.ba.best.com> (raw)


Format has come up on the list a couple times, so I figured I'd ask a question I gave up on trying to solve a while back.

I'd like to write a printer for the top level that will print out matrices as rectangular blocks of numbers, not lists of numbers.  I couldn't figure out whether this was possible with install_printer in a clean way.  The obvious things didn't work quite right.

I finally gave up and ended up with this (open Bigarray first):

let print2d a =
  for i = 0 to Array2.dim1 a - 1 do
    for j = 0 to Array2.dim2 a - 1 do
      Format.printf "%f\t" a.{i,j}
    done;
    Format.printf "\n";
  done

But this doesn't play nice with other printers like it should.  I tried a few different attemps at putting the boxes in, but none worked.  I also read the FAQ, but couldn't quite apply its info to this problem.  Is there a "right" way to do this, or is the Format module not set up for vertical printing?

Chris

-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


             reply	other threads:[~2001-06-12 18:17 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-06-12 18:18 Chris Hecker [this message]
2001-06-12 19:03 ` Markus Mottl
2001-06-12 21:01   ` Chris Hecker
2001-06-13 12:16     ` Hendrik Tews
2001-06-14 19:37       ` Pierre Weis
2001-06-14 19:58         ` Patrick M Doane
2001-06-14 20:36           ` Pierre Weis
2001-06-14 21:35         ` Frank Atanassow
2001-06-15 12:43           ` Pierre Weis
2001-06-15 12:34         ` Hendrik Tews
2001-06-15 17:32           ` Pierre Weis
2001-06-14  6:46     ` Pierre Weis

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=4.3.2.7.2.20010612111351.029b8720@shell16.ba.best.com \
    --to=checker@d6.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;
as well as URLs for NNTP newsgroup(s).