As I intend to use bitvectors to do fast set operations, and cardinality is a set operation, I wrote up a "fast count bits" function that should be rolled in for the vector implementation: https://gist.github.com/4154642
It depends on the fixnum representation, so I don't imagine this being adaptable to the bignum implementation. Bignums would have to support this kind of thing natively, which I don't think is the case. However, if you know the bignum is a fixnum, you could use this. -Ian ----- Original Message ----- From: "Matthew Flatt" <mfl...@cs.utah.edu> To: "Jens Axel Søgaard" <jensa...@soegaard.net> Cc: dev@racket-lang.org Sent: Tuesday, November 27, 2012 9:28:28 AM GMT -05:00 US/Canada Eastern Subject: Re: [racket-dev] Implementation of bit vectors Nicely done. I've merged with minor changes, including renaming `bit-vector-count' to `bit-vector-length' to be more consistent with `vector' functions. At Sat, 24 Nov 2012 20:33:12 +0100, Jens Axel Søgaard wrote: > Hi All, > > I have written an implementation of bit vectors intended to be part of > the data collection. > > https://github.com/plt/racket/pull/176 > > Any comments on the implementation and documentation are welcome. > The bit vector is represented as a vector of fixnums (packaged in a > struct of course). > > -- > Jens Axel Søgaard > > _________________________ > Racket Developers list: > http://lists.racket-lang.org/dev _________________________ Racket Developers list: http://lists.racket-lang.org/dev _________________________ Racket Developers list: http://lists.racket-lang.org/dev