Trouble with lockstep

Joseph Rushton Wakeling joseph.wakeling at webdrake.net
Mon Jun 24 08:29:16 PDT 2013


On 06/24/2013 03:05 PM, Craig Dillabaugh wrote:
> I get the following error messages which I cannot decipher.

Oddly enough, I'm also getting lockstep-related error messages at compile-time:

/opt/gdc/include/d/4.8.1/std/range.d:4716: Error: delegate dg (ref double, ref
ulong) is not callable using argument types (double, ulong)
test.d:122: Error: opApply() function for Lockstep!(Result, ulong[]) must return
an int
/opt/gdc/include/d/4.8.1/std/range.d:4717: Error: delegate dg (ulong, ref
double, ref ulong) is not callable using argument types (ulong, double, ulong)

test.d:122 is a foreach over a lockstep:

    foreach(r, x; itemDegree) ...

where itemDegree is generated by the following function:

    auto degreeRank(NodeT)(NodeT nodes)
    {
        size_t[] x;
        foreach(node; nodes)
            x ~= node.links.length;
        x.sort;
        auto r = iota(1.0, 0, -1.0/x.length);
        return lockstep(r, x);
    }

By the way, yes, I know I can probably find a better and more efficient way to
generate x than what's there.  It's what I wrote some time ago and never had a
pressing enough need to improve. :-P


More information about the Digitalmars-d-learn mailing list