Subject: [clisp-list] Re: pretty-printing multi-dimensional arrays

From: Joe Corneli <[email-masked]>
Date: Mon Mar 8 21:33:02 2004

Could this be made prettier?

[1]> (make-array '(3 3) :initial-contents '((1 2 3) (4 5 9) (7 8 6)))
#2A((1 2 3) (4 5 9) (7 8 6))

Something like this?

[nnn]> (make-array '(3 3) :initial-contents '((1 2 3) (4 5 9) (7 8 6)))
#2A((1 2 3) 
    (4 5 9) 
    (7 8 6))

Actually, I would have expected the latter to be what would be
printed after reading the thread begun by Bruno Haible on Wed, 28
Jan 2004.  BTW, I have

> *print-pretty*
T

---

From: Pascal J.Bourguignon <[email-masked]>
Date: Tue Mar 9 00:20:01 2004

> printed after reading the thread begun by Bruno Haible on Wed, 28

I think it's pretty enough to print it on one line when possible. 

[72]> (make-array '(6 6 ) :initial-element 1)
#2A((1 1 1 1 1 1)
    (1 1 1 1 1 1)
    (1 1 1 1 1 1)
    (1 1 1 1 1 1)
    (1 1 1 1 1 1)
    (1 1 1 1 1 1))

[73]> (make-array '(5 5) :initial-element 1)
#2A((1 1 1 1 1) (1 1 1 1 1) (1 1 1 1 1) (1 1 1 1 1) (1 1 1 1 1))

In any case, specific output functions are needed, because in general
you don't write your matrices as:

 #2A((1 2 3) 
     (4 5 9) 
     (7 8 6))

but as:

    [ 1 4 7 ]
    [ 2 5 8 ]
    [ 3 6 9 ]

anyway.

-- 
__Pascal_Bourguignon__                     http://www.informatimago.com/
There is no worse tyranny than to force a man to pay for what he doesn't
want merely because you think it would be good for him.--Robert Heinlein
http://www.theadvocates.org/