This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Bug in assoc
- From: Jamison Hope <jrh at theptrgroup dot com>
- To: kawa at sourceware dot org
- Date: Wed, 24 Nov 2010 18:21:25 -0500
- Subject: Bug in assoc
According to the SRFI-1 description of assoc:
The comparison procedure is used to compare the elements ei of list
to the key parameter in this way:
(= key (car ei)) ; list is (E1 ... En)
That is, the first argument is always key, and the second argument
is one of the list elements. Thus one can reliably find the first
entry of alist whose key is greater than five with
(assoc 5 alist <)
However, the implementation in kawa.lib.lists passes key as the second
argument instead:
(if (test pair:car x) pair
which means that (assoc 5 alist <) will find the first entry of alist
whose key is *less than* five.
Please apply this patch:
Index: kawa/lib/lists.scm
===================================================================
--- kawa/lib/lists.scm (revision 6825)
+++ kawa/lib/lists.scm (working copy)
@@ -159,5 +159,5 @@
(if (eq? list '())
#f
(let ((pair :: <pair> (car list)))
- (if (test pair:car x) pair
+ (if (test x pair:car) pair
(lp (cdr list)))))))
Thanks,
Jamie
--
Jamison Hope
The PTR Group
www.theptrgroup.com