Trouble with lockstep
bearophile
bearophileHUGS at lycos.com
Mon Jun 24 08:15:45 PDT 2013
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
More information about the Digitalmars-d-learn
mailing list