From 307dbee96cd9791d8c9c972230646ed97ae9833f Mon Sep 17 00:00:00 2001 From: Jan Moringen Date: Sun, 13 Aug 2017 21:51:10 +0200 Subject: [PATCH] New utility function DECIMAL-WITH-GROUPED-DIGITS-WIDTH --- package-data-list.lisp-expr | 1 + src/code/early-extensions.lisp | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/package-data-list.lisp-expr b/package-data-list.lisp-expr index 50f223f27..88ecbe049 100644 --- a/package-data-list.lisp-expr +++ b/package-data-list.lisp-expr @@ -869,6 +869,7 @@ like *STACK-TOP-HINT* and unsupported stuff like *TRACED-FUN-LIST*." "*DISASSEMBLE-ANNOTATE*" "PRINT-SYMBOL-WITH-PREFIX" "PRINT-TYPE-SPECIFIER" "PRINT-TYPE" + "DECIMAL-WITH-GROUPED-DIGITS-WIDTH" ;; stepping interface "STEP-CONDITION" "STEP-FORM-CONDITION" "STEP-FINISHED-CONDITION" diff --git a/src/code/early-extensions.lisp b/src/code/early-extensions.lisp index 84a3b0bd2..cde34f675 100644 --- a/src/code/early-extensions.lisp +++ b/src/code/early-extensions.lisp @@ -1231,6 +1231,12 @@ NOTE: This interface is experimental and subject to change." (defun print-type (stream type &optional colon at) (print-type-specifier stream (type-specifier type) colon at)) +(declaim (ftype (sfunction (index &key (:comma-interval (and (integer 1) index))) index) + decimal-with-grouped-digits-width)) +(defun decimal-with-grouped-digits-width (value &key (comma-interval 3)) + (let ((digits (length (write-to-string value :base 10)))) + (+ digits (floor (1- digits) comma-interval)))) + ;;;; etc. -- 2.11.4.GIT