From a5f53116caf3b3c0c286d1acca9c88369d9a0f13 Mon Sep 17 00:00:00 2001 From: Stephen Adams Date: Thu, 20 Apr 1995 16:03:24 +0000 Subject: [PATCH] Added documentation for BIT-SUBSTRING-FIND-NEXT-SET-BIT. --- v7/doc/ref-manual/scheme.texinfo | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/v7/doc/ref-manual/scheme.texinfo b/v7/doc/ref-manual/scheme.texinfo index 393d60c6d..92f96d6b2 100644 --- a/v7/doc/ref-manual/scheme.texinfo +++ b/v7/doc/ref-manual/scheme.texinfo @@ -2,7 +2,7 @@ @iftex @finalout @end iftex -@comment $Id: scheme.texinfo,v 1.49 1995/03/02 04:56:36 adams Exp $ +@comment $Id: scheme.texinfo,v 1.50 1995/04/20 16:03:24 adams Exp $ @comment %**start of header (This is for running Texinfo on a region.) @setfilename scheme @settitle MIT Scheme Reference @@ -7719,6 +7719,29 @@ Sets the @var{k}th bit in @var{bit-string} to 0 and returns an unspecified value. @var{K} must be a valid index of @var{bit-string}. @end deffn +@deffn {procedure+} bit-substring-find-next-set-bit bit-string start end +@cindex searching, of bit string +Returns the index of the first occurrence of a set bit in the substring +of @var{bit-string} from @var{start} (inclusive) to @var{end} +(exclusive). If none of the bits in the substring are set @code{#f} is +returned. The index returned is relative to the whole bit string, not +substring. + +The following procedure uses @code{bit-substring-find-next-set-bit} to +find all the set bits and display their indexes: +@example +(define (scan-bitstring bs) + (let ((end (bit-string-length bs))) + (let loop ((start 0)) + (let ((next (bit-substring-find-next-set-bit bs start end))) + (if next + (begin + (write-line next) + (if (< next end) + (loop (+ next 1))))))))) +@end example +@end defn + @node Cutting and Pasting Bit Strings, Bitwise Operations on Bit Strings, Selecting Bit String Components, Bit Strings @section Cutting and Pasting Bit Strings @cindex cutting, of bit string -- 2.25.1