caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] pretty printers and format and matrices
@ 2001-06-12 18:18 Chris Hecker
  2001-06-12 19:03 ` Markus Mottl
  0 siblings, 1 reply; 12+ messages in thread
From: Chris Hecker @ 2001-06-12 18:18 UTC (permalink / raw)
  To: caml-list


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


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2001-06-15 17:32 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-12 18:18 [Caml-list] pretty printers and format and matrices Chris Hecker
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

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).