Trouble with lockstep

Craig Dillabaugh cdillaba at cg.scs.carleton.ca
Mon Jun 24 07:05:28 PDT 2013


Hello,
I have code which generates a histogram from an array and prints
out the histogram bins/counts. However I cannot get the code to
iterate and print
out the histogram to work.  The following is a minimal example:

import std.range;
import std.stdio;

void main()
{
    ubyte[] data =
[17,32,32,32,38,39,39,47,47,47,47,109,111,111,128];
    uint[ubyte.max - ubyte.min] bins;

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

    foreach( idx, count; lockstep( iota!ubyte(ubyte.min,
ubyte.max), bins ) )
    {
      if(count > 0 ) {
	writeln("Bin = ", idx, " count = ", count );
      }
    }
}

Alternately:  http://dpaste.com/hold/1267929/

I get the following error messages which I cannot decipher.

test.d(11): Error: template std.range.lockstep does not match any
function template declaration. Candidates are:
/usr/include/dmd/phobos/std/range.d(4724):
std.range.lockstep(Ranges...)(Ranges ranges) if
(allSatisfy!(isInputRange, Ranges))
/usr/include/dmd/phobos/std/range.d(4730):
std.range.lockstep(Ranges...)(Ranges ranges, StoppingPolicy s) if
(allSatisfy!(isInputRange, Ranges))
/usr/include/dmd/phobos/std/range.d(4724): Error: template
std.range.lockstep cannot deduce template function from argument
types !()(Result, uint[255LU])
Failed: 'dmd' '-v' '-o-' 'test.d' '-I.'

Can anyone identify what I am doing wrong.  Also I am curious to
know why std.range includes both Lockstep and lockstep - they
seem like the same thing.

Craig


More information about the Digitalmars-d-learn mailing list