Skip to content

iterator interface #8

@tpapp

Description

@tpapp

Thanks for this great library, I find it very useful. However, I am not sure that the library supports the iteration interface of Julia. Eg Sobol.SobolSeq returns not an iterator, but an iterator and a state. So, for example,

import Sobol

function collect_take(iter, n)
    v = Vector{Float64}(0)
    for (i, x) in enumerate(iter)
        push!(v, x[1])
        if (i >= n)
            break
        end
    end
    v
end
double_take(iter, n) = vcat(collect_take(iter,5), collect_take(iter,5))
double_take(Sobol.SobolSeq(1), 5)

returns the first 10 elements (instead of the first 5, twice). Cf, for example,

double_take(countfrom(1),5)

Also, idioms like

[x[1] for x in take(Sobol.SobolSeq(1),5)]

don't work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions