Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It's a bit of a convolution, but let's say we've got some iterator of unknown size and we want to have a prime each iteration. We can do the following in python, which saves us from having to pre-compute the primes _or_ know how long `some_iterator` is.

primes = gen_primes() for item, prime in zip(some_iterator, primes):



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: