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.length>y.value.length})
above.
providor_symbol_map is an Associative Array, so you can't sort
that.
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.length>y.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 k
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]
>
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
providor_symbol_map.sort!((x,y)=>{x.va
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
Sorry about typo, I meant
providor_symbol_map.sort!((x,y)=>{x.value.length>y.value.length})
above.
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
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 assoc
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].len
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
10 matches
Mail list logo