www.delorie.com/gnu/docs/guile/guile_240.html   search  
 
Buy GNU books!


Guile Reference Manual

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

22.6.4 Bit Vectors

Bit vectors are a specific type of uniform array: an array of booleans with a single zero-based index.

They are displayed as a sequence of 0s and 1s prefixed by #*, e.g.,

 
(make-uniform-vector 8 #t #f) =>
#*00000000

#b(#t #f #t) =>
#*101

Scheme Procedure: bit-count b bitvector
C Function: scm_bit_count (b, bitvector)
Return the number of occurrences of the boolean b in bitvector.

Scheme Procedure: bit-position item v k
C Function: scm_bit_position (item, v, k)
Return the minimum index of an occurrence of bool in bv which is at least k. If no bool occurs within the specified range #f is returned.

Scheme Procedure: bit-invert! v
C Function: scm_bit_invert_x (v)
Modify bv by replacing each element with its negation.

Scheme Procedure: bit-set*! v kv obj
C Function: scm_bit_set_star_x (v, kv, obj)
If uve is a bit-vector bv and uve must be of the same length. If bool is #t, uve is OR'ed into bv; If bool is #f, the inversion of uve is AND'ed into bv.

If uve is a unsigned long integer vector all the elements of uve must be between 0 and the length of bv. The bits of bv corresponding to the indexes in uve are set to bool. The return value is unspecified.

Scheme Procedure: bit-count* v kv obj
C Function: scm_bit_count_star (v, kv, obj)
Return
 
(bit-count (bit-set*! (if bool bv (bit-invert! bv)) uve #t) #t).
bv is not modified.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003