RFC: Parametrize iterators based on applicable(length, it.xs); fixes #25

Some iterators wrap other iterators, and the wrapped iterable may or may not have a defined length.  This PR parametrizes the relevant iterator types based on whether or not `length` is defined for the wrapped iterable, and defines `length` for the iterator only when the wrapped array also has a length.

This is most useful for `collect(itr)`, which preallocates an output array if `length` is defined, or grows the output array otherwise.

Cc: @garborg, @ivarne 

Ref: https://github.com/JuliaLang/julia/issues/7429, #25, #27 
Thanks!  Don't know how I missed that, as I thought I tested this.


On Sun, Jul 6, 2014 at 5:37 AM, Simon Kornblith <notifications@github.com>
wrote:

> In src/Iterators.jl:
>
> >      xs::I
> >      n::Int
> >  end
> >
> >  eltype(it::Take) = eltype(it.xs)
> > -length(it::Take) = it.n
> > +length(it::Take{false}) = it.n
> > +length(it::Take{true}) = min(it.n, length(xs)}
>
> Typo at the end of the line here
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/JuliaLang/Iterators.jl/pull/28/files#r14575013>.
>