std.range should support recursion (Was: One-line FFT, nice!)
monarch_dodra
monarchdodra at gmail.com
Tue Sep 25 09:04:09 PDT 2012
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?
//-----------------------
import std.range;
struct S
{
enum empty = false;
void popFront(){};
@property int front(){return 1;}
}
void main()
{
S foo;
static assert(is(typeof(foo.stride(1)) ==
typeof(foo.stride(2).stride(3))));
static assert(is(typeof(foo.drop(1)) ==
typeof(foo.drop(2).drop(3))));
static assert(is(typeof(foo) == typeof(foo.drop(2)))); //Or this
static assert(is(typeof(foo.take(1)) ==
typeof(foo.take(2).take(3))));
}
//-----------------------
More information about the Digitalmars-d
mailing list