Sorry for the very silly question. I’m trying to figure out how to call the elements of a set. For example in my below example, how do I get the first element, i.e., “Acg”?
A = Set([“Acg”, “Bdc”, “HH”]);
I tried, A[1], A(1), A{1}, but none of them worked.
The default Set in Base is not ordered - there is no “first” element. You may want to check out OrderedSet from DataStructures.jl instead, though usually depending on a specific ordering could also be served by using unique on a regular vector.
It’s a design choice like any other - the common case for a Set is to be unordered, it just happens that some languages like python leak some internal ordering or even guarantee an order, locking them into that decision for backwards compatibility reasons. If the default here is unordered, julia is free to optimize the internal datastructure as much as we want, changing the order to provide more efficient storage etc.
Sure it has its pros and cons, but to me that is a weird thing to be split on. It may also be worthwhile to think about why you need a specific ordering of a Set in the first place, and if a different datastructure may be better suited to the task at hand.