Programming

(Common Lisp) commas separating every three digits

steloflute 2019. 5. 29. 23:46

http://www.gigamonkeys.com/book/a-few-format-recipes.html

You can also modify the behavior of some directives with colon and at-sign modifiers, which are placed after any prefix parameters and before the directive's identifying character. These modifiers change the behavior of the directive in small ways. For instance, with a colon modifier, the ~D directive used to output integers in decimal emits the number with commas separating every three digits, while the at-sign modifier causes ~D to include a plus sign when the number is positive.

CL-USER> (format t "~d" 1000000)

1000000 NIL

CL-USER> (format t "~:d" 1000000)

1,000,000 NIL

CL-USER> (format t "~@d" 1000000)

+1000000 NIL

'Programming' 카테고리의 다른 글

Haskell은 별로다.  (0) 2019.10.19
[Python] setup.py 를 이용하여 모듈 설치  (0) 2019.08.08
History of Lisp  (0) 2019.05.29
Descending sort in Haskell  (0) 2019.05.28
Python virtualenv 정리 (Linux/Windows)  (0) 2018.12.10