Version 1 of commas added to numbers

Updated 2005-11-09 20:05:26

What: commas added to numbers

 Where: From the contact
 Description: Tiny Tcl regsub comma to add commas to numbers, taking
        leading white space, - or +, and decimal points into account.
 Updated:
 Contact: mailto:[email protected] (John Allen)

In Bag of algorithms there a one-liner alternative by Peter Spjuth (in the Tcl chatroom, 2004-10-05) using modern regexp features:

 proc commify number {regsub -all {\d(?=(\d{3})+($|\.))} $number {\0,}}

[ Category Package | Category Mathematics ]