Use the Perl-compatible regular expression engine to insert the commas where needed. It's simplest to reverse the string prior to the regexp-pass so that we can hop over any decimal portion. Then reverse the string back on return.

In addition to Erlang's various other string-related ills (mainly poor memory and time performance), it has a very limited set of regular expressions. For example, our implementation of partition_number
is over twice as long as the [[http://schemecookbook.org/view/Cookbook/NumberRecipeCommas][Scheme alternative] because
it has no look-ahead (or negative look-ahead) searching functionality.