Craig Dillabaugh:

I now get the error (which seems to be the same problem I had
before - see the last error):
...
/usr/include/dmd/phobos/std/range.d(4451): Error: template
std.range.zip cannot deduce template function from argument types
!()(Result, uint[256LU])

Most range/algorithm functions unfortunately don't accept a fixes size array. So you have to slice it:

void main() {
    import std.stdio, std.range;

    ubyte[] data = [17, 32, 32, 32, 38, 39, 39, 47,
                    47, 47, 47, 109, 111, 111, 128];
    uint[ubyte.max - ubyte.min + 1] bins;

    foreach (immutable val; data)
        bins[val]++;

foreach (uint idx, count; iota(ubyte.min, ubyte.max + 1).zip(bins[]))
        if (count > 0)
            writeln("Bin = ", idx, " count = ", count);
}

Bye,
bearophile

Reply via email to