unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: "Zack Weinberg" <zack@owlfolio.org>
To: guile-devel@gnu.org
Subject: [guile-lib] PATCH: fix primes.scm
Date: Thu, 23 May 2024 19:35:36 -0400	[thread overview]
Message-ID: <62c87a83-210a-40dd-9092-5c92d2e2a391@app.fastmail.com> (raw)

primes.scm appears never to have been updated for the new bitvector API
(in Guile 3?), causing both build and test failures.

The appended patch (vs 0.2.8.1) fixes the failures I am seeing.
Assuming this is indeed an API change in Guile 3, I do not know what it
would take to make this code work with both, and I ask that you take it
from here.

zw

--- a/src/math/primes.scm	2024-05-23 19:26:16.757865343 -0400
+++ b/src/math/primes.scm	2024-05-23 19:28:20.797358650 -0400
@@ -114,7 +114,7 @@
 		      (set! prime:prime-sqr (* nexp nexp))
 		      (set! prime:sieve (make-bitvector nexp #f))
 		      (for-each (lambda (prime)
-				  (bitvector-set! prime:sieve prime #t))
+				  (bitvector-set-bit! prime:sieve prime))
 				primes)
 		      (set! prime:products (reverse (cons comp comps))))
 		     (else
@@ -132,7 +132,7 @@
 There is a slight chance, @code{(expt 2 (- prime:trials))}, that a 
 composite will return @code{#t}."
   (set! n (abs n))
-  (cond ((< n (bitvector-length prime:sieve)) (bitvector-ref prime:sieve n))
+  (cond ((< n (bitvector-length prime:sieve)) (bitvector-bit-set? prime:sieve n))
 	((even? n) #f)
 	((primes-gcd? n prime:products) #f)
 	((< n prime:prime-sqr) #t)



                 reply	other threads:[~2024-05-23 23:35 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=62c87a83-210a-40dd-9092-5c92d2e2a391@app.fastmail.com \
    --to=zack@owlfolio.org \
    --cc=guile-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).