Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Convert set to vector

This seems like a really easy thing, but believe it or not my google search hasn’t brought me anywhere. I want to be able to convert a set to a vector. I have tried the following:

sett=Set{Int64}([1,2,3])
vecc=convert(Vector{Int64},sett)

but it appears Julia doesn’t know how to do these conversions.

One obvious thing I can do is using comprehensions e.g.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

vecc=[el for el in sett]

but is there not a more elegant way?

Cheers in advance.

>Solution :

Splatting can be problematic from a performance perspective. Instead, use

vecc = collect(sett) 
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading