std.algorithm range violation

maarten van damme via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed May 28 04:11:21 PDT 2014


I'm trying to analyze the usage of certain words in a large number of spam
emails, and I want for every interesting word a list of 'providors', that
mentioned that word. with associative arrays I hoped to get it by using
array["interestingworde].

And I have to refer outside from sort(x,y) as associative arrays have no
order, I'll always have to sort a key-array according to values obtained
through the associative array.
It's supposed to be a delegate anyway, otherwise the least it could do is
throw a compilation error.


2014-05-28 12:53 GMT+02:00 Wanderer via Digitalmars-d-learn <
digitalmars-d-learn at puremagic.com>:

> On Wednesday, 28 May 2014 at 10:10:41 UTC, maarten van damme via
>
> Digitalmars-d-learn wrote:
>
>> an anyone explain me what I'm doing wrong here :
>>
>> [code]
>> dstring[][dstring] providor_symbol_map;
>> ...
>>
>> writeln(providor_symbol_map.keys.sort!((x,y)=>providor_
>> symbol_map[x].length>=providor_symbol_map[y].length));
>> [/code]
>>
>> output:
>> core.exception.RangeError at std.algorithm(9429): Range violation
>>
>
> "dstring[][dstring]" declaration looks a bit obscure to me...
> what do you intent with it, "array of maps" or "map of arrays"?
>
> Also, it looks unnatural that inside sorting lambda, you refer
> outside from it (back to providor_symbol_map variable). Ideally,
> you should only use variables x and y. Does D support sorting by
> map entries instead of by keys only or by values only?
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20140528/33a6bb68/attachment.html>


More information about the Digitalmars-d-learn mailing list