Skip to content

Commit

Permalink
make Iterators available for Inference usage
Browse files Browse the repository at this point in the history
  • Loading branch information
vtjnash committed Dec 27, 2017
1 parent ec6afca commit ca7b665
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions base/coreimg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ include("reduce.jl")
include("bitarray.jl")
include("bitset.jl")
include("abstractdict.jl")
include("iterators.jl")
include("namedtuple.jl")

# core docsystem
Expand Down
15 changes: 10 additions & 5 deletions base/iterators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,21 @@ Methods for working with Iterators.
"""
module Iterators

import Base:
# small dance to make this work from Base or Intrinsics
import ..@__MODULE__, ..module_parent
const Base = module_parent(@__MODULE__)
using .Base:
@inline, Pair, AbstractDict, IndexLinear, IndexCartesian, IndexStyle, AbstractVector, Vector,
tail, tuple_type_head, tuple_type_tail, tuple_type_cons, SizeUnknown, HasLength, HasShape,
IsInfinite, EltypeUnknown, HasEltype, OneTo, @propagate_inbounds, Generator, AbstractRange

import .Base:
start, done, next, first, last,
isempty, length, size, axes, ndims,
eltype, iteratorsize, iteratoreltype,
haskey, keys, values, pairs,
getindex, setindex!, get

using Base: tail, tuple_type_head, tuple_type_tail, tuple_type_cons, SizeUnknown, HasLength, HasShape,
IsInfinite, EltypeUnknown, HasEltype, OneTo, @propagate_inbounds, Generator, AbstractRange

export enumerate, zip, rest, countfrom, take, drop, cycle, repeated, product, flatten, partition

_min_length(a, b, ::IsInfinite, ::IsInfinite) = min(length(a),length(b)) # inherit behaviour, error
Expand Down Expand Up @@ -222,7 +227,7 @@ size(v::IndexValue) = size(v.itr)
@propagate_inbounds function next(v::IndexValue, state)
indx, n = next(v.itr, state)
item = v.data[indx]
(indx => item), n
return (Pair(indx, item), n)
end
@inline done(v::IndexValue, state) = done(v.itr, state)

Expand Down

0 comments on commit ca7b665

Please sign in to comment.