help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: elisp to put commas a number?


From: Herbert Euler
Subject: RE: elisp to put commas a number?
Date: Fri, 13 Jun 2008 20:36:34 +0800

Sorry, that doesn't cover the case of n = 0.  This one:

(defun commify (n)
  (if (= n 0)
      "0"
    (let ((list '()))
      (while (> n 0)
        (setq list (cons (format "%d" (% n 1000)) list)
              n (/ n 1000)))
      (mapconcat (lambda (s) s) list ","))))

Regards,
Guanpeng Xu
_________________________________________________________________
Connect to the next generation of MSN Messenger 
http://imagine-msn.com/messenger/launch80/default.aspx?locale=en-us&source=wlmailtagline



reply via email to

[Prev in Thread] Current Thread [Next in Thread]