El domingo, 23 de febrero de 2014 18:09:36 UTC-6, Jeff Bezanson escribió: > > This was just changed on master so that you'd do Set([i*2 for i in 1:5]). >
OK, that seems reasonable, thanks. > On Sun, Feb 23, 2014 at 12:45 AM, David P. Sanders > <[email protected]<javascript:>> > wrote: > > > > > > El viernes, 21 de febrero de 2014 16:03:19 UTC-6, Steven G. Johnson > > escribió: > >> > >> > >> > >> 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 > > > > > > OK, this is the conclusion I had reached, thanks. > > > >> > >> > >> 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. > > > > > > Sounds good! > > >
