On Friday, February 21, 2014 9:02:48 AM UTC-5, David P. Sanders wrote:
>
> OK, I think I have answered my own question: a Set is the good structure.
> And to create a set from an array I can do something like
>
> s = Set([3, 4, 5]...)
>
> or
>
> s = Set([i*2 for i in 1:5]...)
>
> which would be the closest thing to a set comprehension?
>
The closest thing that avoids the overhead of creating an array first would
currently be a loop:
s = Set(Int)
for i in 1:5
push!(s, i*2)
end
At some point, if (when?)
https://github.com/JuliaLang/julia/issues/4470
gets added, it will be easy to add support for syntax like Set(Int, i*2 for
i in 1:5), where the second argument implicitly creates an iterable type.