import std.algorithm, std.math, std.range;
typeof(R.init.stride(0)) dft(R)(R v)
{
        return v.length <= 1
        ? v.stride(1)
        : (p =>
           chain(map!(q => q[0] + q[1])(p),
                 map!(q => q[0] - q[1])(p)))
          (zip(dft(v.stride(2)),
                map!(p => p[1] * expi(p[0] * -2 * PI / v.length))
                (zip(iota(v.length / 2),
                 dft(v.drop(1).stride(2))))));
}
void main() { dft([1.0, 2, 3]); }


Which gives the following error:


Test.d(5): Error: incompatible types for ((stride(v,1u)) ? ((*delegate @system Result(Zip!(Result,MapResult!(__lambda8,Zip!(Result,Result))) p)
{
        return chain(map(p),map(p));
}
)(zip(dft(stride(v,2u)),map(zip(iota(v.length() / 2u),dft(stride(drop(v,1u),2u)))))))): 'Result' and 'Result' Test.d(10): Error: template instance Test.dft!(Result) error instantiating
Test.d:19: instantiated from here: dft!(double[])
Test.d(5): Error: incompatible types for ((stride(v,1u)) ? ((*delegate @system Result(Zip!(Result,MapResult!(__lambda8,Zip!(Result,Result))) p)
{
        return chain(map(p),map(p));
}
)(zip(dft(stride(v,2u)),map(zip(iota(v.length / 2u),dft(stride(drop(v,1u),2u)))))))): 'Result' and 'Result' Test.d(19): Error: template instance Test.dft!(double[]) error instantiating



How should I interpret it?

Thanks!

One possible reason for this error could be that you are returning a result of chain() if length is larger than 1 and a result of stride() otherwise.

Reply via email to