What wrong did i do? (key in hashtable is always null)

bearophile bearophileHUGS at lycos.com
Wed Dec 30 23:34:36 PST 2009

The Anh Tran:
> This is just a small D exercise. I port c++ knucleotide from 
> shootout.alioth.debian.org

This was my version, maybe it solves some of your problems:

I haven't used my dlibs here, so for example that sort in the middle is long and ugly (and not fully correct, that opCmp doesn't compare accordingly both key and value, as the problem specs state: "sorted by descending frequency and then ascending k-nucleotide key"), in Python it becomes:
l = sorted(frequences.items(), reverse=True, key=lambda (seq,freq): (freq,seq))
With my dlibs it's similar. You can probably do something similar with Phobos2.

By the way, the formatting of your code needs improvements, reduce indentation length and format code in a more readable way.


More information about the Digitalmars-d-learn mailing list