Function: bool-vector-count-population

bool-vector-count-population is a function defined in data.c.

Signature

(bool-vector-count-population A)

Documentation

Count how many elements in A are t.

A is a bool vector. To count A's nil elements, subtract the return value from A's length.

View in manual

Probably introduced at or before Emacs version 24.4.

Source Code

// Defined in /usr/src/emacs/src/data.c
{
  EMACS_INT count;
  EMACS_INT nr_bits;
  bits_word *adata;
  ptrdiff_t i, nwords;

  CHECK_BOOL_VECTOR (a);

  nr_bits = bool_vector_size (a);
  nwords = bool_vector_words (nr_bits);
  count = 0;
  adata = bool_vector_data (a);

  for (i = 0; i < nwords; i++)
    count += stdc_count_ones (adata[i]);

  return make_fixnum (count);
}