JuliaLang/julia — pull request #1260 by dcjones (2012-09-06 02:07:51+00:00)
Title: Some helpful iterators

I've implemented a few iterators, along the lines of the python itertools module which I found myself missing. Other might find this useful so I've stuck it in Iterators module in extras.

Synopsis:
```julia
import Iterators.*

count() # 1, 2, 3, ...
count(10) # 10, 11, 12, ...
count(2, 2) # 2, 4, 6, ...
chain([:a, :b, :c], 1:3) # :a, :b, :c, 1, 2, 3
cycle([:a, :b, :c]) # :a, :b, :c, :a, :b, :c, ...
repeat(:a) # :a, :a, :a, ...
repeat(:a, n) # :a, :a, :a, ... (n times)
take([:a, :b, :c], 2) # :a, :b
drop([:a, :b, :c], 1) # :c
product([:a, :b, :c], 1:3) # (:a, 1), (:b, 1), (:c, 1), (:a, 2), (:b, 2), ...
```

Most of these iterators or of indeterminate or infinite length, so don't have a `length` function. Others can be either indeterminate or not depending on what they applied to. In such cases it would be helpful if there were a convention for determining if an iterator is of fixed length. Maybe defining a `length` function that returns `nothing` or some other special value.