On Tuesday, 25 September 2012 at 16:03:22 UTC, monarch_dodra wrote:
On Tuesday, 25 September 2012 at 15:41:42 UTC, Mehrdad wrote:
On Tuesday, 25 September 2012 at 13:34:28 UTC, Andrei Alexandrescu wrote:
On 9/25/12 4:23 AM, Mehrdad wrote:
On Tuesday, 25 September 2012 at 08:21:39 UTC, Mehrdad wrote:
without creating new times


new types**

Ah, better now. Still it would be great to explain it more :o).

Andrei

Haha ok. :) I mean like, essentially, these need to work:

assert(is(typeof(foo.stride(1)) == typeof(foo.stride(2).stride(3))));
assert(is(typeof(foo.drop(1)) == typeof(foo.drop(2).drop(3))));
assert(is(typeof(foo.take(1)) == typeof(foo.take(2).take(3))));

I can't comment on the rest of your points, but stride and take DO check for type recursivity, and drop always returns the same type as input anyways. Failure of ANY of these asserts is a bug. What where your inputs?


I just wrote down the assert's on the fly, actually.
Maybe I'm just misinterpreting the error then, and the problem is somewhere else?
The code I was trying to compile is this (sorry it's ugly):

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!

Reply via email to