Summary: std.range.count() too
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos

--- Comment #0 from 2012-04-05 17:59:57 PDT ---
I'd like a count() in std.range. It's similar to the generator with the same
name in the Python itertools module:

a count() is also useful with bigints, where you can't replace it with

A bare-bones implementation that shows it basic semantics (but it's useful to
add few more methods):

struct Count(T) {
    T n;
    this(T n_) { this.n = n_; }
    const bool empty = false;
    @property T front() { return n; }
    void popFront() { /* n++; */ n += 1; }

// Two helper functions
Count!T count(T)(T start) { return Count!T(start); }
Count!T count(T)() { return Count!T(cast(T)0); }

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to