['a', 'b'].toSet returns a HashSet[char], not a set[char]['a', 'b'].toHashSet is not definedcard is defined for both set and HashSet, but len is defined for HashSet only, not setecho({'a', 'b', 'c', 'b'}.card) : 4 (that one is already reported here: I can agree only with point 3 on len
Number 4 was resolved a day ago by #7558.
len and card in HashSets are the same function with a different name - number 3 could be easily solved by aliasing.
That leaves first two points to consider/solve.
/cc @narimiran
That leaves first two points to consider/solve.
Well assuming number 3 could be easily solved by aliasing is done :-)
actually i don't even know why we need card at all, seems like pointless aliasing that introduces a new symbol ; len is what's used everywhere else. Why not mark card as deprecated?
@timotheecour you could make it a pr that uses the deprecated pragma, I would vote for it.
The deprecated pragma doesn't work for procs.
set and HashSet are different things, set is not a linear type, as in you can't do for i in 0..<x.len: echo x[i] easily. HashSet is a length attribute and a seq of hashes and elements, so it's easy to know that its length is the length of the seq it uses, but set has a different implementation that might make the term "length" misleading.
The length of a set is essentially one or more popcount operations, which are exposed in bitops, so it seems to me not really problematic
Not an inconsistency between sets and HashSets, but while we're talking about what should be implemented:
The thing missing from both versions is pop, which should remove and return a random element from a (hash)set.
Well I disagre on pop.
I think the rest is fine, at one point you have to stop whining and read some documentation.
https://github.com/nim-lang/Nim/pull/11885 fixed item 3 in top post
Most helpful comment
/cc @narimiran
Well assuming
number 3 could be easily solved by aliasingis done :-)actually i don't even know why we need
cardat all, seems like pointless aliasing that introduces a new symbol ;lenis what's used everywhere else. Why not markcardas deprecated?