guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] 03/05: (scheme base) member: return #f, not (), for no m


From: Rob Browning
Subject: [Guile-commits] 03/05: (scheme base) member: return #f, not (), for no match
Date: Sun, 17 Jan 2021 15:05:56 -0500 (EST)

rlb pushed a commit to branch master
in repository guile.

commit f1547e1d58ae369538bf4b6c8f12c6db1399e8c7
Author: Rob Browning <rlb@defaultvalue.org>
AuthorDate: Sun Oct 4 10:43:09 2020 -0500

    (scheme base) member: return #f, not (), for no match
    
    * module/scheme/base.scm (member): Match the r7rs requirement, as assoc
      already does.
    
    Thanks to Erik Dominikus for reporting the problem.
    
    Closes: 43304
---
 THANKS                     | 2 ++
 module/scheme/base.scm     | 7 ++++---
 test-suite/tests/r7rs.test | 2 +-
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/THANKS b/THANKS
index 3d59c50..aa4877e 100644
--- a/THANKS
+++ b/THANKS
@@ -2,6 +2,7 @@ Contributors since the last release:
 
     Christopher Baines
            Greg Benison
+           Rob Browning
         Tristan Colgate-McFarlane
           Aleix Conchillo Flaqué
         Ludovic Courtès
@@ -79,6 +80,7 @@ For fixes or providing information which led to a fix:
            Josh Datko
           David Diffenbaugh
           Hyper Division
+           Erik Dominikus
       Alexandre Duret-Lutz
            Nils Durner
          John W Eaton
diff --git a/module/scheme/base.scm b/module/scheme/base.scm
index b97259f..20e2804 100644
--- a/module/scheme/base.scm
+++ b/module/scheme/base.scm
@@ -129,9 +129,10 @@
     (unless (procedure? =)
       (error "not a procedure" =))
     (let lp ((ls ls))
-      (if (or (null? ls) (= (car ls) x))
-          ls
-          (lp (cdr ls)))))))
+      (cond
+       ((null? ls) #f)
+       ((= (car ls) x) ls)
+       (else (lp (cdr ls))))))))
 
 (define* (assoc x ls #:optional (= equal?))
   (cond
diff --git a/test-suite/tests/r7rs.test b/test-suite/tests/r7rs.test
index 0914f0c..1cc8cd3 100644
--- a/test-suite/tests/r7rs.test
+++ b/test-suite/tests/r7rs.test
@@ -2171,7 +2171,7 @@
        (let ((out (open-output-string))
              (x (list 1)))
          (set-cdr! x x)
-         (write x out)
+         (write-shared x out)
          (get-output-string out))
        ;; labels not guaranteed to be 0 indexed, spacing may differ
        '("#0=(1 . #0#)" "#1=(1 . #1#)"))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]