I need some help with the format
function and arrays.
My objective is to print a 2 dimensional array of N·N integer values as N integers per line. For example:
#2A((1 2 3)
(4 5 6)
(7 8 9))
should be printed as
1 2 3
4 5 6
7 8 9
I couldn't find any documentation on how to use format
to print arrays. Can it actually be done, or should I convert my array into a list and use something like:
(format t "~{~%~{~A~^ ~}~}" list)
(defun show-board (board)
(loop for i below (car (array-dimensions board)) do
(loop for j below (cadr (array-dimensions board)) do
(let ((cell (aref board i j)))
(format t "~a " cell)))
(format t "~%")))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With