My question is:
How can I set the precision of my REPL print output?
As an example, this simple function here:
(defun gaussian (rows cols sigma)
(let ((filter (make-array `(,rows ,cols)))
(rowOffset (/ (- rows 1) 2.0))
(colOffset (/ (- cols 1) 2.0)))
(loop for i from 0 to (- rows 1)
do (loop for j from 0 to (- cols 1)
do (setf (aref filter i j)
(gaussDistVal i j rowOffset ColOffset sigma))))
filter))
If I call (gaussian 5 5 1)
, my output is the following:
#2A((0.01831564 0.082085 0.13533528 0.082085 0.01831564)
(0.082085 0.36787945 0.60653067 0.36787945 0.082085)
(0.13533528 0.60653067 1.0 0.60653067 0.13533528)
(0.082085 0.36787945 0.60653067 0.36787945 0.082085)
(0.01831564 0.082085 0.13533528 0.082085 0.01831564))
Whereas I'd like to get:
#2A((0.0 0.1 0.1 0.1 0.0)
(0.0 0.4 0.6 0.4 0.1)
(0.1 0.6 1.0 0.6 0.1)
(0.0 0.4 0.6 0.4 0.1)
(0.0 0.1 0.1 0.1 0.0))
If you have the answer, could you also please tell me where these "REPL customisations" are documented?
(SBCL 1.2.11; Slime on Emacs 25)
loop
s might be better expressed asdotimes
:(dotimes (i rows) (dotimes (j cols) #| .... |#)
. – Geary(loop for i from 0 below rows...
(and thefrom 0
is optional) instead of(loop for i from 0 to (- rows 1)...
or (if you absolutely want to do arithmetic on your bounds)(1- rows)
. – Junji