Using the iteration interface with custom indices

julia> function Base.iterate(I::CustomIndexSet,i::CustomIndex)
           if i.i <= I.n
               return i,CustomIndex(i.i+1)
           else
               return nothing
           end
       end

julia> for i in CustomIndexSet(4)
              @show i
           end
i = CustomIndex(1)
i = CustomIndex(2)
i = CustomIndex(3)
i = CustomIndex(4)

difference on line 3

2 Likes