On Monday, 24 June 2013 at 15:15:46 UTC, bearophile wrote:
Craig Dillabaugh:

clip

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

Thanks.  Now it works, if I use .zip().

Reply via email to