Collections in Julia need to support three functions to be iterable: start, next, and done.
Is there currently a way to express that an input x to a function needs to be iterable within the type system? If not, is this on the roadmap?
Is it possible? Yes, but not in a very elegant way:
julia> x = 1:5
1:5
julia> applicable(start, x)
true
julia> applicable(next,x,start(x))
true
julia> applicable(done,x,start(x))
true
I'm not sure how to get around the need for the start(x)
s - maybe checking for start
will be "good enough".
As for a more sensible way, this would need multiple inheritance or interfaces, which is under discussion, e.g. here is one issue, it links to others.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With