Less coding

bearophile bearophileHUGS at lycos.com
Mon Feb 25 18:13:54 PST 2008


Using the set it can written like this too:

void main() {
    string chars = letters ~ digits;
    auto tests = Set!(int);
    do {
        tests ~= map((int i){ return choice(chars);}, xrange(randInt(1, 24)));
    } while (tests.length < 50000);

    foreach(nf, func; [&hash2, &hash3, &hash4, &hash5, &hash6, &hash7])
        putr("hash", nf+2, ": ", tests.length - set(xmap(func, tests)).length);
}

Bye,
bearophile



More information about the Digitalmars-d mailing list