What features of D are you using now which you thought you'd never goint to use?

monarch_dodra monarchdodra at gmail.com
Mon Jun 24 23:39:09 PDT 2013


On Monday, 24 June 2013 at 23:11:29 UTC, Timon Gehr wrote:
> On 06/23/2013 11:20 PM, Timon Gehr wrote:
>> On 06/23/2013 01:34 PM, monarch_dodra wrote:
>>> ...
>>>
>>> But as soon as you need an algorithm that actually *handles* 
>>> ranges:
>>> swaps them, merges them, searches in them and splices them, 
>>> then things
>>> get hairy.
>>>
>>> For example, try implementing a sort (either merge or q) with 
>>> a
>>> non-sliceable range... very very hard...
>>
>> Challenge accepted.
>>
>> http://dpaste.dzfl.pl/4407c36f
>
> (stable merge sort, comparison function as template argument: 
> http://dpaste.dzfl.pl/9bf21773)

Nice. You could probably get some better performance with a 
takeExactly (heck, take exactly would be a *better* choice, since 
it asserts there is actually what you asked for, rather than "up 
to").

All I can say is well done, though I still feel the use of 
"take"s are clutches that shouldn't actually be needed, and are 
making the overall code more complicated (and slower) than it 
should be.

It can be done, but I find it to be tougher and less enjoyable 
than with actual iterators: You iterate until you reach your 
pivot, and then you should be able to simply have two ranges on 
each side.


More information about the Digitalmars-d mailing list