[Issue 9550] Repeat!fun(size_t n)

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Feb 20 00:16:24 PST 2013


http://d.puremagic.com/issues/show_bug.cgi?id=9550


monarchdodra at gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |monarchdodra at gmail.com


--- Comment #1 from monarchdodra at gmail.com 2013-02-20 00:16:07 PST ---
Isn't what you are asking for a special case of sequence that discards any and
all input?

//----
int fun(T)(T/+Tuple!()+/, uint n)
{
    static int i;
    return ++++i;
}

void main()
{
    auto a = sequence!fun();
    writeln(a.take(10));
}
//----
[2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
//----

In this case "T" is a tuple containing the empty state, and n is the iteration
count.

Apart from the fancy sig, it's what you are asking for.

Given that the signature of "fun" isn't specified yet, we could special case
sequence for sequences that have no initial state, to simply call fun(n) (as
well as be more efficient). 

I think it would be a good idea. So I'll look into doing that. PS: could you
link the mentioned discussion, it could help.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list