Iota
Paul Backus
snarwin at gmail.com
Thu Aug 4 21:31:02 UTC 2022
On Thursday, 4 August 2022 at 19:06:43 UTC, H. S. Teoh wrote:
> After thinking about this, I think in its barest essentials,
> the only version of iota we need is the one that takes a single
> int argument, and that generates that many numbers, starting
> from 0. Everything else can be built on top of this with other
> existing library functions.
Strictly speaking, you don't even need that; all you need is a
range that generates the natural numbers, and you can write
naturals.take(n)
...to get the equivalent of iota(n).
That said, I don't think you have to aim for total minimalism to
avoid generality creep here. You just need to know what iota's
purpose for inclusion is, so that you can say "no, that's not
iota's job; use generate/recurrence/something else instead" when
someone proposes an overly-general enhancement.
I wonder if perhaps iota was vulnerable to generality creep in
part because it was copied into Phobos from C++'s STL, without a
lot of thought given to what specific purpose it served in
relation to the rest of the library.
More information about the Digitalmars-d
mailing list