-
-
Notifications
You must be signed in to change notification settings - Fork 705
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
std.range.countFrom() too #9924
Labels
Comments
bearophile_hugs commented on 2012-04-23T13:54:31ZAnd 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. |
bearophile_hugs commented on 2012-04-24T19:43:36Zstd.algorithm has a function named count(), so this range will need a different name. Maybe countFrom()? |
bearophile_hugs commented on 2012-04-24T19:47:13ZChanged the name of this issue from "std.range.count() too" to "std.range.countFrom() too". |
greensunny12 commented on 2017-07-12T17:16:28ZWouldn't it make sense to add support for BigInt to iota instead of creating yet another range? |
me commented on 2018-01-26T21:03:31Z(In reply to Seb from comment #4)
> Wouldn't it make sense to add support for BigInt to iota instead of creating
> yet another range?
From what I understand the itertools.count doesn't accetp an upperbound while iota forces the user to specify the upper bound.
Did I understand that correctly? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
bearophile_hugs reported this on 2012-04-05T17:59:57Z
Transfered from https://issues.dlang.org/show_bug.cgi?id=7839
CC List
Description
The text was updated successfully, but these errors were encountered: