Skip to content

Instantly share code, notes, and snippets.

@hidsh
Created November 7, 2011 19:14
Show Gist options
  • Save hidsh/1345854 to your computer and use it in GitHub Desktop.
Save hidsh/1345854 to your computer and use it in GitHub Desktop.
桁数を求める for xyzzy
(defun digit (n)
"return digit for number."
(setq n (truncate (1+ n)))
(let ((d 0))
(while (> n 1)
(setq n (/ n 10))
(incf d))
d))
;; (digit 1000)
;; =>4
;; (digit 999)
;; =>3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment