R.filter!(..).sort!(..)

Steven Schveighoffer schveiguy at yahoo.com
Tue Nov 28 14:04:40 UTC 2017


On 11/28/17 8:57 AM, Arjan wrote:
> On Tuesday, 28 November 2017 at 13:24:09 UTC, Steven Schveighoffer wrote:
>> On 11/28/17 8:10 AM, Arjan wrote:
>>> [...]
>>
>> The library is correctly telling you that your filtered range is not 
>> random access. It can't be, because it lazily applies the filter (that 
>> is, it filters on each element as you popFront them). So how can it 
>> know what the e.g. 3rd element is, if you haven't run any filters yet?
>>
>> The array version works because you are applying the filter completely 
>> and storing the results elsewhere in one step.
>>
> 
> Well I would have liked an error msg something like: 
> isRandomAccessRange!Range for Range=.. failed! Or unable to sort!() a 
> lazy Range.

Sure, the error messages could be more specific about WHY it's failing. 
This has been discussed many times, but no action has been taken.

Would be an awesome project to add to D.

-Steve


More information about the Digitalmars-d-learn mailing list