Open dlfivefifty opened 6 years ago
Union and intersection should probably always return sets. It's almost always the most efficient method, and it would improve consistency.
For better or for worse, this is pretty much written in stone until 2.0.
For better or for worse, this is pretty much written in stone until 2.0.
Sure, this can wait til 2.0. In the meantime I'll do a proposed "replacement" in LazyArrays.jl that can be considered for moving into Base when 2.0 development starts.
Union and intersection should probably always return sets
I assume you mean a subtype of AbstractSet
: if we have sparse vectors a Set
won't necessarily be the most efficient. I'm also not sure this works when its infinite sets like intervals, where the elements cannot be enumerated, but that depends on the currently undefined definition of AbstractSet
.
Yeah, that's probably true.
at least it can be specified in the docstrings, something like union(S{A},I{B}) -> S{C}
where elements of both types A
and B
are promotable/convertible to C
Here's a proposed solution: https://github.com/JuliaArrays/LazyArrays.jl/blob/master/src/lazysetoperations.jl
This is surprising:
In the process of fixing this, I'd propose support more general union types (like Intervals, see https://github.com/JuliaMath/IntervalSets.jl/issues/41) I'd propose redesigning
union
to use a lazyUnioned
intermediary that mimicsBroadcasted
. I might make a proof-of-concept in LazyArrays.jl.CC @timholy