Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] pretty printers and format and matrices
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Chris Hecker <checker@d...>
Subject: [Caml-list] pretty printers and format and matrices

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}
    Format.printf "\n";

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?


Bug reports:  FAQ:
To unsubscribe, mail  Archives: