Zero-alignment nose alignment

There is a directive formatfor zero digits.

cl-user> (format nil "~12,'0d" 27)
"000000000027"

and there is a similar directive for left-justifying rows when they are added

cl-user> (format nil "~12@<~d~>" 27)
"27          "

Is there a way to do both? I.e:

cl-user> (format nil "~12,something,d" 27)
"270000000000"

Naive "~12,'0@<~d~>"doesn't seem to do what I want here.

cl-user> (format nil "~12,'0@<~d~>" 27)
"27          "
+4
source share
2 answers

In the last example, you are close, but you need some more commas, because the tilde takes four arguments less , and pad char is the fourth argument, but you pass it as the second. Just pass it as fourth:

CL-USER> (format nil "~12,,,'0@<~d~>" 27)
"270000000000"

, , , . , . , , . , , - 0. , . 000027 ( ) 27, , 000027 (, , ), . 270000, , , 0

+6

~A:

(format nil "~33,,,'0A" 27)
==>  "270000000000000000000000000000000"
+5

All Articles