On Sun, 11 Feb 2007 19:15:44 +0000, Ken Bloom wrote:

> On Sun, 11 Feb 2007 06:30:52 -0800, Phrogz wrote:
> 
>> Here are my solutions to Quiz #113. For some of them I just couldn't
>> help but to provide a couple variations.
>> 
>> Because I'm a terrible golfer, most strive for elegance (in some form)
>> over terseness.
>> 
>> 
>> # 1 - Commafy Numerics
>> i,f=quiz.to_s.split('.'); i.gsub(/(\d)(?=\d{3}+$)/,'\\1,') + (f ?
>> ('.'+f) : '')
> 
> Good answer. you helped me golf mine down a little bit by getting rid of
> array indexing:
> 
> i,f=i.to_s.split('.');"#{i.reverse.scan(/.{1,3}/).join(',').reverse}.#{f}"

Another answer, based on yours, this one is exactly one expression (no
semicolons):
quiz.to_s.gsub(/(\d)(?=\d{3}+#{quiz.to_s=~/\./?/\./:/$/})/,'\\1,')


-- 
Ken Bloom. PhD candidate. Linguistic Cognition Laboratory.
Department of Computer Science. Illinois Institute of Technology.
http://www.iit.edu/~kbloom1/