http://d.puremagic.com/issues/show_bug.cgi?id=7839
Summary: std.range.count() too Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: Phobos AssignedTo: nob...@puremagic.com ReportedBy: bearophile_h...@eml.cc --- Comment #0 from bearophile_h...@eml.cc 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: http://docs.python.org/library/itertools.html#itertools.count a count() is also useful with bigints, where you can't replace it with iota(BigInt.max). 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: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------