std.algorithm range violation

2014-05-28 Thread maarten van damme via Digitalmars-d-learn
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@std.algorithm(9429): Range violation

Re: std.algorithm range violation

2014-05-28 Thread Wanderer via Digitalmars-d-learn
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; ...

Re: std.algorithm range violation

2014-05-28 Thread maarten van damme via Digitalmars-d-learn
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

Re: std.algorithm range violation

2014-05-28 Thread bearophile via Digitalmars-d-learn
maarten van damme: writeln(providor_symbol_map.keys.sort!((x,y)=providor_symbol_map[x].length=providor_symbol_map[y].length)); [/code] Try: ((x, y) = providor_symbol_map[x].length providor_symbol_map[y].length) Bye, bearophile

Re: std.algorithm range violation

2014-05-28 Thread Wanderer via Digitalmars-d-learn
Sorry about typo, I meant providor_symbol_map.sort!((x,y)={x.value.lengthy.value.length}) above.

Re: std.algorithm range violation

2014-05-28 Thread Wanderer via Digitalmars-d-learn
Aha, so you want to maintain spam word - set of senders relationship, so it's actually map of sets and your declaration is correct. You only need to sort map's entries (key and value pairs together). If D supports that, it should be something like

Re: std.algorithm range violation

2014-05-28 Thread bearophile via Digitalmars-d-learn
Wanderer: providor_symbol_map.sort!((x,y)={x.value.length=y.value.length}), This lambda doesn't return a boolean. Also, add spaces around operators and after commas. Bye, bearophile

Re: std.algorithm range violation

2014-05-28 Thread maarten van damme via Digitalmars-d-learn
wow. senpai, teach me what I did wrong... 2014-05-28 13:21 GMT+02:00 bearophile via Digitalmars-d-learn digitalmars-d-learn@puremagic.com: maarten van damme: writeln(providor_symbol_map.keys.sort!((x,y)=providor_ symbol_map[x].length=providor_symbol_map[y].length)); [/code] Try:

Re: std.algorithm range violation

2014-05-28 Thread monarch_dodra via Digitalmars-d-learn
On Wednesday, 28 May 2014 at 11:40:05 UTC, Wanderer wrote: Sorry about typo, I meant providor_symbol_map.sort!((x,y)={x.value.lengthy.value.length}) above. providor_symbol_map is an Associative Array, so you can't sort that. *Usually*, you want to do what the OP did, which is to get the

Re: std.algorithm range violation

2014-05-28 Thread monarch_dodra via Digitalmars-d-learn
On Wednesday, 28 May 2014 at 17:39:15 UTC, monarch_dodra wrote: On Wednesday, 28 May 2014 at 11:40:05 UTC, Wanderer wrote: Sorry about typo, I meant providor_symbol_map.sort!((x,y)={x.value.lengthy.value.length}) above. providor_symbol_map is an Associative Array, so you can't sort that.