[Issue 7839] std.range.count() too

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Apr 23 13:53:33 PDT 2012


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



--- Comment #1 from bearophile_hugs at eml.cc 2012-04-23 13:54:31 PDT ---
And answer to a question by jerro in D.learn:

http://forum.dlang.org/thread/4F949E90.9060700@webdrake.net#post-evdrwckxsqieyrweuxzp:40forum.dlang.org

> Couldn't it just be iota with no parameters?

The Count range has a helper count() function similar to this, that's meant to
have an argument that defaults to zero:

Count!T count(T)(T start=0) if (isIntegral!T) { return Count!T(start); }

The argument allows it to start from another starting point, and it allows you
to specify the type of the numbers it yields, while in iota() without arguments
it's less easy to specify the type of the numbers it yields.

Count(5) is easy to replace with iota(5, int.max), but count(BigInt(0)) is less
easy to replace with iota, because it doesn't give you a way to denote a
right-open BigInt interval. And using iota(BigInt(0), BigInt(ulong.max)) is not
that good. Currently using BigInt in iota seems to not even being supported.

-- 
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