[swift-evolution] About the PermutationGenerator

Dmitri Gribenko gribozavr at gmail.com
Thu Dec 31 07:59:38 CST 2015


On Thu, Dec 31, 2015 at 3:51 PM, Tino Heth <2th at gmx.de> wrote:
>> Those are collections.  Collections can be iterated over multiple times.
> Speaking of the Fibonacci-numbers:
> Sure we can write an algorithm that iterates over them several times — it just won't ever finish the first iteration ;-)
> (only nitpicking — I just couldn't resist)

Well, I didn't say you need to iterate to the very end, or that you
need to iterate them serially.  You can take two generators from the
same collection, and advance them independently, in interleaved
fashion, for example.

Dmitri

-- 
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/


More information about the swift-evolution mailing list