is there anyway to find the length of a number e.g.
(length 1234567890)
would equal 10, or:(length 5487)
would equal 4Discuss and learn Lisp programming of all dialects
This is a read-only archive of lispforum.com. The forum was locked to new users and posts and is preserved here as static HTML from a database snapshot taken on 2019-09-07.
4 posts · 4333 views
(length 1234567890)
would equal 10, or:(length 5487)
would equal 4(defun number-length (num)
(if (zerop num)
1
(1+ (floor (log num 10)))))
or text-representation-way:
(defun number-length (num)
(length (format nil "~s" num)))