On 05/17/2016 12:53 AM, Alex wrote:
Just as the reality (in my head) is: you can count something without
having written the natural numbers before you start to count...

iota does that, too. A iota struct doesn't store all the numbers it will emit. Just like a slice, a iota struct stores two numbers: the first and the amount of numbers. Iterating over it means counting, not reading pre-generated numbers from a list.

Especially, I don't have to create some strange structs containing just
a number, as I expect to have some millions of them.

Some million slices will take just as much space as some million iota structs. Storing a slice isn't free. If you create the slices on the fly, you can do that with iota too. No need to store them beforehand.

Reply via email to