can't zip a char[5], string[5], real[5]

Shriramana Sharma via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Oct 21 07:06:47 PDT 2015


import std.stdio, std.range;
void mywrite(char [5] chars, real[5] vals)
{
    static string [5] fmts = ["%9.4f, ", "%9.4f; ", "%3d, ", "%3d, ", 
"%3d\n"];
    foreach (e; zip(chars, fmts, vals)) write(e[0], " = ", 
e[1].format(e[2]));
}

Compiling gives:

zip_string.d(5): Error: template std.range.zip cannot deduce function from 
argument types !()(char[5], string[5], real[5]), candidates are:
/usr/include/dmd/phobos/std/range/package.d(3678):        
std.range.zip(Ranges...)(Ranges ranges) if (Ranges.length && allSatisfy!
(isInputRange, Ranges))
/usr/include/dmd/phobos/std/range/package.d(3711):        
std.range.zip(Ranges...)(StoppingPolicy sp, Ranges ranges) if (Ranges.length 
&& allSatisfy!(isInputRange, Ranges))

I would have thought there would be no problem in creating a zip of three 
arrays of equal length. What's the problem here?

-- 
Shriramana Sharma, Penguin #395953


More information about the Digitalmars-d-learn mailing list