Closed oscbyspro closed 3 weeks ago
Hm. I suppose it's possible to preserve the count(...) format with something like count(ascending:).
Some of it is motivated by brevity, but I also don't want alphabet soup.
Hm. I thought about adding BinaryInteger/entropy() but I'm not yet sure. Conceptually the return type should be a signed machine word because the magnitude of an unsigned 1-bit integer cannot represent the entropy 2-bit of 1. At the same time, returning non-magnitudes when bit counting is rather unexpected. I suppose doing nothing is an option. It's a bit wordy at the moment, but view types would fix that:
x.elements.entropy() // vs x.withUnsafeBinaryIntegerElements({ $0.entropy() })
Edit: 1-bit integers are banned because machines don't like them, but still.
Having used the
count(Bit.Selection)
methods for a while now, I think I would prefer something simpler.