Rosetta Commatizing numbers

Ivan Kazmenko via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jun 1 05:15:12 PDT 2017


On Thursday, 1 June 2017 at 08:45:23 UTC, Solomon E wrote:
> On Wednesday, 31 May 2017 at 15:44:51 UTC, Ivan Kazmenko wrote:
> ....
>>
>> So, two custom calls, two minor changes, no sweat.  Is 
>> everything right now?  Even if not: that was fast, we can do 
>> another iteration.  When we have a short readable solution 
>> with no special cases, the first few changes are going to be 
>> easy.
>>
> ....
>>
>> Ivan Kazmenko.
>
> I followed that advice, and found and fixed more bugs that were 
> lurking in the original and in my complications. When the 
> number begins with a decimal point, that's an edge case none of 
> the earlier versions were handling right. I added a regression 
> test for that.
>
> I just posted my latest version at Rosetta, without the 
> unnecessary complications. I hope you like it better.
>
> http://rosettacode.org/wiki/Commatizing_numbers#D
>
> (The complications weren't totally useless though. Without 
> trying the complications, I wouldn't have tested enough to make 
> as much improvement as I have. Overcomplicated features are 
> something to avoid releasing, except in a repo folder of extras 
> for other programmers to try fiddling with, and Rosetta code 
> isn't exactly that.)

I very much like the current version.  It is concise, has no 
arbitrary constants in implementation, and does the job better 
than the version before your edits.

As for commatizeSpec (which is currently removed), I still 
believe it is too magically specialized to be useful.  But as 
long as vanilla commatize is available, I'd see commatizeSpec as 
just a way to run the tests, and be fine with it.

Thank you for bearing with me, and being a better listener than I 
am.

Ivan Kazmenko.



More information about the Digitalmars-d-learn mailing list